Commit af5b5e62 authored by Hante Meuleman's avatar Hante Meuleman Committed by Kalle Valo
Browse files

brcmfmac: merge platform data and module paramaters



Merge module parameters and platform data in one struct. This is the
last step to move to the new platform data per device. Now parameters
of platform data will be merged with module parameters per device.

Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Reviewed-by: default avatarFranky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4d792895
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -109,8 +109,8 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
	u32 addr, gpiocontrol;
	unsigned long flags;

	pdata = sdiodev->pdata;
	if ((pdata) && (pdata->oob_irq_supported)) {
	pdata = &sdiodev->settings->bus.sdio;
	if (pdata->oob_irq_supported) {
		brcmf_dbg(SDIO, "Enter, register OOB IRQ %d\n",
			  pdata->oob_irq_nr);
		ret = request_irq(pdata->oob_irq_nr, brcmf_sdiod_oob_irqhandler,
@@ -177,8 +177,8 @@ int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)

	brcmf_dbg(SDIO, "Entering\n");

	pdata = sdiodev->pdata;
	if ((pdata) && (pdata->oob_irq_supported)) {
	pdata = &sdiodev->settings->bus.sdio;
	if (pdata->oob_irq_supported) {
		sdio_claim_host(sdiodev->func[1]);
		brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
		brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
@@ -522,7 +522,7 @@ static int brcmf_sdiod_sglist_rw(struct brcmf_sdio_dev *sdiodev, uint fn,
	target_list = pktlist;
	/* for host with broken sg support, prepare a page aligned list */
	__skb_queue_head_init(&local_list);
	if (sdiodev->pdata && sdiodev->pdata->broken_sg_support && !write) {
	if (!write && sdiodev->settings->bus.sdio.broken_sg_support) {
		req_sz = 0;
		skb_queue_walk(pktlist, pkt_next)
			req_sz += pkt_next->len;
@@ -629,7 +629,7 @@ static int brcmf_sdiod_sglist_rw(struct brcmf_sdio_dev *sdiodev, uint fn,
		}
	}

	if (sdiodev->pdata && sdiodev->pdata->broken_sg_support && !write) {
	if (!write && sdiodev->settings->bus.sdio.broken_sg_support) {
		local_pkt_next = local_list.next;
		orig_offset = 0;
		skb_queue_walk(pktlist, pkt_next) {
@@ -900,7 +900,7 @@ void brcmf_sdiod_sgtable_alloc(struct brcmf_sdio_dev *sdiodev)
		return;

	nents = max_t(uint, BRCMF_DEFAULT_RXGLOM_SIZE,
		      sdiodev->bus_if->drvr->settings->sdiod_txglomsz);
		      sdiodev->settings->bus.sdio.txglomsz);
	nents += (nents >> 4) + 1;

	WARN_ON(nents > sdiodev->max_segment_count);
@@ -912,7 +912,7 @@ void brcmf_sdiod_sgtable_alloc(struct brcmf_sdio_dev *sdiodev)
		sdiodev->sg_support = false;
	}

	sdiodev->txglomsz = sdiodev->bus_if->drvr->settings->sdiod_txglomsz;
	sdiodev->txglomsz = sdiodev->settings->bus.sdio.txglomsz;
}

#ifdef CONFIG_PM_SLEEP
@@ -1246,8 +1246,8 @@ static int brcmf_ops_sdio_suspend(struct device *dev)

	sdio_flags = MMC_PM_KEEP_POWER;
	if (sdiodev->wowl_enabled) {
		if (sdiodev->pdata->oob_irq_supported)
			enable_irq_wake(sdiodev->pdata->oob_irq_nr);
		if (sdiodev->settings->bus.sdio.oob_irq_supported)
			enable_irq_wake(sdiodev->settings->bus.sdio.oob_irq_nr);
		else
			sdio_flags |= MMC_PM_WAKE_SDIO_IRQ;
	}
+3 −1
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ enum brcmf_bus_protocol_type {
	BRCMF_PROTO_MSGBUF
};

struct brcmf_mp_device;

struct brcmf_bus_dcmd {
	char *name;
	char *param;
@@ -217,7 +219,7 @@ bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt,
void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp);

/* Indication from bus module regarding presence/insertion of dongle. */
int brcmf_attach(struct device *dev);
int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings);
/* Indication from bus module regarding removal/absence of dongle */
void brcmf_detach(struct device *dev);
/* Indication from bus module that dongle should be reset */
+40 −28
Original line number Diff line number Diff line
@@ -243,14 +243,35 @@ static void brcmf_mp_attach(void)
	}
}

struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
					       enum brcmf_bus_type bus_type,
					       u32 chip, u32 chiprev)
{
	struct brcmfmac_sdio_pd *pdata;
	struct brcmf_mp_device *settings;
	struct brcmfmac_pd_device *device_pd;
	bool found;
	int i;

	brcmf_dbg(INFO, "Enter, bus=%d, chip=%d, rev=%d\n", bus_type, chip,
		  chiprev);
	settings = kzalloc(sizeof(*settings), GFP_ATOMIC);
	if (!settings)
		return NULL;

	/* start by using the module paramaters */
	settings->p2p_enable = !!brcmf_p2p_enable;
	settings->feature_disable = brcmf_feature_disable;
	settings->fcmode = brcmf_fcmode;
	settings->roamoff = !!brcmf_roamoff;
#ifdef DEBUG
	settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
#endif

	if (bus_type == BRCMF_BUSTYPE_SDIO)
		settings->bus.sdio.txglomsz = brcmf_sdiod_txglomsz;

	/* See if there is any device specific platform data configured */
	found = false;
	if (brcmfmac_pdata) {
		for (i = 0; i < brcmfmac_pdata->device_count; i++) {
			device_pd = &brcmfmac_pdata->devices[i];
@@ -259,38 +280,29 @@ struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
			    ((device_pd->rev == chiprev) ||
			     (device_pd->rev == -1))) {
				brcmf_dbg(INFO, "Platform data for device found\n");
				settings->country_codes =
						device_pd->country_codes;
				if (device_pd->bus_type == BRCMF_BUSTYPE_SDIO)
					return &device_pd->bus.sdio;
					memcpy(&settings->bus.sdio,
					       &device_pd->bus.sdio,
					       sizeof(settings->bus.sdio));
				found = true;
				break;
			}
		}
	}
	pdata = NULL;
	brcmf_of_probe(dev, &pdata);

	return pdata;
	if ((bus_type == BRCMF_BUSTYPE_SDIO) && (!found)) {
		/* No platform data for this device. In case of SDIO try OF
		 * (Open Firwmare) Device Tree.
		 */
		brcmf_of_probe(dev, &settings->bus.sdio);
	}

int brcmf_mp_device_attach(struct brcmf_pub *drvr)
{
	drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
	if (!drvr->settings)
		return -ENOMEM;

	drvr->settings->sdiod_txglomsz = brcmf_sdiod_txglomsz;
	drvr->settings->p2p_enable = !!brcmf_p2p_enable;
	drvr->settings->feature_disable = brcmf_feature_disable;
	drvr->settings->fcmode = brcmf_fcmode;
	drvr->settings->roamoff = !!brcmf_roamoff;
#ifdef DEBUG
	drvr->settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
#endif
	return 0;
	return settings;
}

void brcmf_mp_device_detach(struct brcmf_pub *drvr)
void brcmf_release_module_param(struct brcmf_mp_device *module_param)
{
	kfree(drvr->settings);
	kfree(module_param);
}

static int __init brcmf_common_pd_probe(struct platform_device *pdev)
+14 −25
Original line number Diff line number Diff line
@@ -45,41 +45,30 @@ extern struct brcmf_mp_global_t brcmf_mp_global;
/**
 * struct brcmf_mp_device - Device module paramaters.
 *
 * @sdiod_txglomsz: SDIO txglom size.
 * @joinboost_5g_rssi: 5g rssi booost for preferred join selection.
 * @p2p_enable: Legacy P2P0 enable (old wpa_supplicant).
 * @feature_disable: Feature_disable bitmask.
 * @fcmode: FWS flow control.
 * @roamoff: Firmware roaming off?
 * @ignore_probe_fail: Ignore probe failure.
 * @country_codes: If available, pointer to struct for translating country codes
 * @bus: Bus specific platform data. Only SDIO at the mmoment.
 */
struct brcmf_mp_device {
	int	sdiod_txglomsz;
	int	joinboost_5g_rssi;
	bool		p2p_enable;
	int	feature_disable;
	unsigned int	feature_disable;
	int		fcmode;
	bool		roamoff;
	bool		ignore_probe_fail;
	struct brcmfmac_pd_cc *country_codes;
	union {
		struct brcmfmac_sdio_pd sdio;
	} bus;
};

struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
					       enum brcmf_bus_type bus_type,
					       u32 chip, u32 chiprev);
int brcmf_mp_device_attach(struct brcmf_pub *drvr);
void brcmf_mp_device_detach(struct brcmf_pub *drvr);
#ifdef DEBUG
static inline bool brcmf_ignoring_probe_fail(struct brcmf_pub *drvr)
{
	return drvr->settings->ignore_probe_fail;
}
#else
static inline bool brcmf_ignoring_probe_fail(struct brcmf_pub *drvr)
{
	return false;
}
#endif
void brcmf_release_module_param(struct brcmf_mp_device *module_param);

/* Sets dongle media info (drv_version, mac address). */
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
+3 −8
Original line number Diff line number Diff line
@@ -1104,7 +1104,7 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb,
}
#endif

int brcmf_attach(struct device *dev)
int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
{
	struct brcmf_pub *drvr = NULL;
	int ret = 0;
@@ -1126,10 +1126,7 @@ int brcmf_attach(struct device *dev)
	drvr->hdrlen = 0;
	drvr->bus_if = dev_get_drvdata(dev);
	drvr->bus_if->drvr = drvr;

	/* Initialize device specific settings */
	if (brcmf_mp_device_attach(drvr))
		goto fail;
	drvr->settings = settings;

	/* attach debug facilities */
	brcmf_debug_attach(drvr);
@@ -1274,7 +1271,7 @@ fail:
		brcmf_net_detach(p2p_ifp->ndev);
	drvr->iflist[0] = NULL;
	drvr->iflist[1] = NULL;
	if (brcmf_ignoring_probe_fail(drvr))
	if (drvr->settings->ignore_probe_fail)
		ret = 0;

	return ret;
@@ -1350,8 +1347,6 @@ void brcmf_detach(struct device *dev)

	brcmf_proto_detach(drvr);

	brcmf_mp_device_detach(drvr);

	brcmf_debug_detach(drvr);
	bus_if->drvr = NULL;
	kfree(drvr);
Loading