bhnd_chipc_if.m revision 301408
1#- 2# Copyright (c) 2016 Landon Fuller <landon@landonf.org> 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 23# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24# 25# $FreeBSD: head/sys/dev/bhnd/cores/chipc/bhnd_chipc_if.m 301408 2016-06-04 19:31:06Z landonf $ 26 27#include <sys/types.h> 28#include <sys/bus.h> 29 30#include <dev/bhnd/bhnd.h> 31#include <dev/bhnd/nvram/bhnd_nvram.h> 32 33INTERFACE bhnd_chipc; 34 35# 36# bhnd(4) ChipCommon interface. 37# 38 39HEADER { 40 /* forward declarations */ 41 struct chipc_caps; 42 struct chipc_caps *bhnd_chipc_generic_get_caps(device_t dev); 43} 44 45CODE { 46 47 /** 48 * Helper function for implementing BHND_CHIPC_GET_CAPS(). 49 * 50 * This implementation of BHND_CHIPC_GET_CAPS() simply calls the 51 * BHND_CHIPC_GET_CAPS() method of the parent of @p dev. 52 */ 53 struct chipc_caps* 54 bhnd_chipc_generic_get_caps(device_t dev) 55 { 56 57 if (device_get_parent(dev) != NULL) 58 return (BHND_CHIPC_GET_CAPS(device_get_parent(dev))); 59 60 panic("bhnd_chipc_generic_get_caps unimplemented"); 61 /* Unreachable */ 62 return (NULL); 63 } 64 65} 66 67/** 68 * Return the preferred NVRAM data source. 69 * 70 * @param dev A bhnd(4) ChipCommon device. 71 */ 72METHOD bhnd_nvram_src_t nvram_src { 73 device_t dev; 74} 75 76/** 77 * Write @p value with @p mask directly to the chipctrl register. 78 * 79 * @param dev A bhnd(4) ChipCommon device. 80 * @param value The value to write. 81 * @param mask The mask of bits to be written from @p value. 82 * 83 * Drivers should only use function for functionality that is not 84 * available via another bhnd_chipc() function. 85 * 86 * Currently, the only known valid use-case is in implementing a hardware 87 * work-around for the BCM4321 PCIe rev7 core revision. 88 */ 89METHOD void write_chipctrl { 90 device_t dev; 91 uint32_t value; 92 uint32_t mask; 93} 94 95/** 96 * Return a borrowed reference to ChipCommon's capability 97 * table. 98 * 99 * @param dev A bhnd(4) ChipCommon device 100 */ 101METHOD struct chipc_caps * get_caps { 102 device_t dev; 103} DEFAULT bhnd_chipc_generic_get_caps; 104 105/** 106 * Enable hardware access to the SPROM. 107 * 108 * @param sc chipc driver state. 109 * 110 * @retval 0 success 111 * @retval EBUSY If enabling the hardware may conflict with 112 * other active devices. 113 */ 114METHOD int enable_sprom { 115 device_t dev; 116} 117 118/** 119 * Release hardware access to the SPROM. 120 * 121 * @param sc chipc driver state. 122 */ 123METHOD void disable_sprom { 124 device_t dev; 125} 126