Path: blob/main/sys/dev/bhnd/cores/chipc/chipcvar.h
39566 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2015-2016 Landon Fuller <[email protected]>4* Copyright (c) 2017 The FreeBSD Foundation5* All rights reserved.6*7* Portions of this software were developed by Landon Fuller8* under sponsorship from the FreeBSD Foundation.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer,15* without modification.16* 2. Redistributions in binary form must reproduce at minimum a disclaimer17* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any18* redistribution must be conditioned upon including a substantially19* similar Disclaimer requirement for further binary redistribution.20*21* NO WARRANTY22* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS23* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT24* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY25* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL26* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,27* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF28* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS29* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER30* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)31* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF32* THE POSSIBILITY OF SUCH DAMAGES.33*34*/3536#ifndef _BHND_CORES_CHIPC_CHIPCVAR_H_37#define _BHND_CORES_CHIPC_CHIPCVAR_H_3839#include <sys/types.h>40#include <sys/rman.h>4142#include <dev/bhnd/nvram/bhnd_spromvar.h>4344#include "chipc.h"4546DECLARE_CLASS(bhnd_chipc_driver);4748struct chipc_region;4950const char *chipc_flash_name(chipc_flash type);51const char *chipc_flash_bus_name(chipc_flash type);52const char *chipc_sflash_device_name(chipc_flash type);5354/*55* ChipCommon device quirks / features56*/57enum {58/** No quirks */59CHIPC_QUIRK_NONE = 0,6061/**62* ChipCommon-controlled SPROM/OTP is supported, along with the63* CHIPC_CAP_SPROM capability flag.64*/65CHIPC_QUIRK_SUPPORTS_SPROM = (1<<1),6667/**68* The BCM4706 NAND flash interface is supported, along with the69* CHIPC_CAP_4706_NFLASH capability flag.70*/71CHIPC_QUIRK_4706_NFLASH = (1<<2),7273/**74* The SPROM is attached via muxed pins. The pins must be switched75* to allow reading/writing.76*/77CHIPC_QUIRK_MUX_SPROM = (1<<3),7879/**80* Access to the SPROM uses pins shared with the 802.11a external PA.81*82* On modules using these 4331 packages, the CCTRL4331_EXTPA_EN flag83* must be cleared to allow SPROM access.84*/85CHIPC_QUIRK_4331_EXTPA_MUX_SPROM = (1<<4) |86CHIPC_QUIRK_MUX_SPROM,8788/**89* Access to the SPROM uses pins shared with the 802.11a external PA.90*91* On modules using these 4331 chip packages, the external PA is92* attached via GPIO 2, 5, and sprom_dout pins.93*94* When enabling and disabling EXTPA to allow SPROM access, the95* CCTRL4331_EXTPA_ON_GPIO2_5 flag must also be set or cleared,96* respectively.97*/98CHIPC_QUIRK_4331_GPIO2_5_MUX_SPROM = (1<<5) |99CHIPC_QUIRK_4331_EXTPA_MUX_SPROM,100101/**102* Access to the SPROM uses pins shared with two 802.11a external PAs.103*104* When enabling and disabling EXTPA, the CCTRL4331_EXTPA_EN2 must also105* be cleared to allow SPROM access.106*/107CHIPC_QUIRK_4331_EXTPA2_MUX_SPROM = (1<<6) |108CHIPC_QUIRK_4331_EXTPA_MUX_SPROM,109110/**111* SPROM pins are muxed with the FEM control lines on this 4360-family112* device. The muxed pins must be switched to allow reading/writing113* the SPROM.114*/115CHIPC_QUIRK_4360_FEM_MUX_SPROM = (1<<5) |116CHIPC_QUIRK_MUX_SPROM,117118/** Supports CHIPC_CAPABILITIES_EXT register */119CHIPC_QUIRK_SUPPORTS_CAP_EXT = (1<<6),120121/** Supports HND or IPX OTP registers (CHIPC_OTPST, CHIPC_OTPCTRL,122* CHIPC_OTPPROG) */123CHIPC_QUIRK_SUPPORTS_OTP = (1<<7),124125/** Supports HND OTP registers. */126CHIPC_QUIRK_OTP_HND = (1<<8) |127CHIPC_QUIRK_SUPPORTS_OTP,128129/** Supports IPX OTP registers. */130CHIPC_QUIRK_OTP_IPX = (1<<9) |131CHIPC_QUIRK_SUPPORTS_OTP,132133/** OTP size is defined via CHIPC_OTPLAYOUT register in later134* ChipCommon revisions using the 'IPX' OTP controller. */135CHIPC_QUIRK_IPX_OTPL_SIZE = (1<<10)136};137138/**139* chipc child device info.140*/141struct chipc_devinfo {142struct resource_list resources; /**< child resources */143rman_res_t irq; /**< child IRQ, if mapped */144bool irq_mapped; /**< true if IRQ mapped, false otherwise */145};146147/**148* chipc driver instance state.149*/150struct chipc_softc {151device_t dev;152153struct bhnd_resource *core; /**< core registers. */154struct chipc_region *core_region; /**< region containing core registers */155156uint32_t quirks; /**< chipc quirk flags */157struct chipc_caps caps; /**< chipc capabilities */158159struct mtx mtx; /**< state mutex. */160size_t sprom_refcnt; /**< SPROM pin enable refcount */161struct rman mem_rman; /**< port memory manager */162STAILQ_HEAD(, chipc_region) mem_regions;/**< memory allocation records */163};164165#define CHIPC_LOCK_INIT(sc) \166mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \167"BHND chipc driver lock", MTX_DEF)168#define CHIPC_LOCK(sc) mtx_lock(&(sc)->mtx)169#define CHIPC_UNLOCK(sc) mtx_unlock(&(sc)->mtx)170#define CHIPC_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->mtx, what)171#define CHIPC_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx)172173#endif /* _BHND_CORES_CHIPC_CHIPCVAR_H_ */174175176