Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nanopi2 #330

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
net: wireless: Support for AP6210 (bcm4336)
  • Loading branch information
hmz007 authored and anatol committed Mar 17, 2016
commit 93bfefe05ada09f4e8b986cd61dd354eb28cf259
20 changes: 8 additions & 12 deletions arch/arm/configs/nanopi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ CONFIG_S3C2416_SETUP_SDHCI_GPIO=y
#
# S3C2416 Boards
#
CONFIG_WL_WEXT=y
CONFIG_MACH_MINI2451=y
# CONFIG_MACH_SMDK2416 is not set
# CONFIG_MACH_S3C2416_DT is not set
Expand Down Expand Up @@ -596,7 +595,7 @@ CONFIG_INET_TCP_DIAG=y
CONFIG_TCP_CONG_CUBIC=y
CONFIG_DEFAULT_TCP_CONG="cubic"
# CONFIG_TCP_MD5SIG is not set
CONFIG_IPV6=m
CONFIG_IPV6=y
CONFIG_IPV6_ROUTER_PREF=y
# CONFIG_IPV6_ROUTE_INFO is not set
# CONFIG_IPV6_OPTIMISTIC_DAD is not set
Expand Down Expand Up @@ -878,11 +877,8 @@ CONFIG_BQL=y
# CONFIG_AF_RXRPC is not set
CONFIG_FIB_RULES=y
CONFIG_WIRELESS=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_SPY=y
CONFIG_WEXT_PRIV=y
CONFIG_CFG80211=y
# CONFIG_NL80211_TESTMODE is not set
# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
Expand Down Expand Up @@ -1129,13 +1125,13 @@ CONFIG_WLAN=y
# CONFIG_USB_ZD1201 is not set
# CONFIG_USB_NET_RNDIS_WLAN is not set
# CONFIG_ATH_CARDS is not set
CONFIG_BRCMUTIL=m
CONFIG_BRCMFMAC=m
CONFIG_BRCMFMAC_PROTO_BCDC=y
CONFIG_BRCMFMAC_SDIO=y
# CONFIG_BRCMFMAC_USB is not set
# CONFIG_BRCM_TRACING is not set
# CONFIG_BRCMDBG is not set
CONFIG_BCMDHD=y
CONFIG_BCMDHD_FW_PATH="/lib/firmware/ap6210/fw_bcmdhd.bin"
CONFIG_BCMDHD_NVRAM_PATH="/lib/firmware/ap6210/nvram.txt"
CONFIG_BCMDHD_CONFIG_PATH="/lib/firmware/ap6210/config.txt"
CONFIG_BCMDHD_OOB=y
# CONFIG_BCMDHD_SDIO_IRQ is not set
# CONFIG_BRCMFMAC is not set
# CONFIG_HOSTAP is not set
# CONFIG_LIBERTAS is not set
# CONFIG_WL_TI is not set
Expand Down
59 changes: 59 additions & 0 deletions arch/arm/mach-s3c24xx/mach-mini2451.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <plat/cpu.h>
#include <plat/pm.h>
#include <linux/platform_data/mtd-nand-s3c2410.h>
#include <linux/mmc/host.h>
#include <plat/sdhci.h>
#include <linux/platform_data/usb-ohci-s3c2410.h>
#include <linux/platform_data/usb-s3c2410_udc.h>
Expand Down Expand Up @@ -290,10 +291,68 @@ static void __init mini2451_fb_init_pdata(struct s3c_fb_platdata *pd) {
pd->vidcon1 = val;
}

#if defined(CONFIG_BCMDHD)
/* Broadcom WI-FI support */
static DEFINE_MUTEX(notify_lock);

#define DEFINE_MMC_CARD_NOTIFIER(num) \
static void (*hsmmc##num##_notify_func)(struct platform_device *, int state); \
static int ext_cd_init_hsmmc##num(void (*notify_func)( \
struct platform_device *, int state)) \
{ \
mutex_lock(&notify_lock); \
WARN_ON(hsmmc##num##_notify_func); \
hsmmc##num##_notify_func = notify_func; \
mutex_unlock(&notify_lock); \
return 0; \
} \
static int ext_cd_cleanup_hsmmc##num(void (*notify_func)( \
struct platform_device *, int state)) \
{ \
mutex_lock(&notify_lock); \
WARN_ON(hsmmc##num##_notify_func != notify_func); \
hsmmc##num##_notify_func = NULL; \
mutex_unlock(&notify_lock); \
return 0; \
}

#ifdef CONFIG_S3C_DEV_HSMMC
DEFINE_MMC_CARD_NOTIFIER(0)
#endif

/*
* call this when you need sd stack to recognize insertion or removal of card
* that can't be told by SDHCI regs
*/
void mmc_force_presence_change_onoff(struct platform_device *pdev, int val)
{
void (*notify_func)(struct platform_device *, int state) = NULL;
mutex_lock(&notify_lock);
#ifdef CONFIG_S3C_DEV_HSMMC
if (pdev == &s3c_device_hsmmc0)
notify_func = hsmmc0_notify_func;
#endif

if (notify_func)
notify_func(pdev, val);
else
pr_warn("%s: called for device with no notifier\n", __func__);
mutex_unlock(&notify_lock);
}
EXPORT_SYMBOL_GPL(mmc_force_presence_change_onoff);
#endif

/* HSMMC */
static struct s3c_sdhci_platdata mini2451_hsmmc0_pdata __initdata = {
.max_width = 4,
#if defined(CONFIG_BCMDHD)
.cd_type = S3C_SDHCI_CD_EXTERNAL,
.pm_flags = MMC_PM_KEEP_POWER | MMC_PM_IGNORE_PM_NOTIFY,
.ext_cd_init = ext_cd_init_hsmmc0,
.ext_cd_cleanup = ext_cd_cleanup_hsmmc0,
#else
.cd_type = S3C_SDHCI_CD_NONE,
#endif
};

static int mini2451_hsmmc1_get_ro(void *host) {
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/plat-samsung/platformdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
set->host_caps2 |= pd->host_caps2;
if (pd->pm_caps)
set->pm_caps |= pd->pm_caps;
if (pd->pm_flags)
set->pm_flags |= pd->pm_flags;
if (pd->get_ro)
set->get_ro = pd->get_ro;
}
6 changes: 6 additions & 0 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/export.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/suspend.h>

#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
Expand Down Expand Up @@ -393,6 +394,8 @@ int mmc_add_host(struct mmc_host *host)

mmc_start_host(host);
mmc_register_pm_notifier(host);
if (!(host->pm_flags & MMC_PM_IGNORE_PM_NOTIFY))
register_pm_notifier(&host->pm_notify);

return 0;
}
Expand All @@ -410,6 +413,9 @@ EXPORT_SYMBOL(mmc_add_host);
void mmc_remove_host(struct mmc_host *host)
{
mmc_unregister_pm_notifier(host);
if (!(host->pm_flags & MMC_PM_IGNORE_PM_NOTIFY))
unregister_pm_notifier(&host->pm_notify);

mmc_stop_host(host);

#ifdef CONFIG_DEBUG_FS
Expand Down
37 changes: 37 additions & 0 deletions drivers/mmc/core/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,3 +1175,40 @@ int mmc_attach_sdio(struct mmc_host *host)
return err;
}

int sdio_reset_comm(struct mmc_card *card)
{
struct mmc_host *host = card->host;
u32 ocr, rocr;
int err;

printk("%s():\n", __func__);
mmc_claim_host(host);

mmc_go_idle(host);

mmc_set_clock(host, host->f_min);

err = mmc_send_io_op_cond(host, 0, &ocr);
if (err)
goto err;

rocr = mmc_select_voltage(host, ocr);
if (!rocr) {
err = -EINVAL;
goto err;
}

err = mmc_sdio_init_card(host, rocr, card, 0);
if (err)
goto err;

mmc_release_host(host);
return 0;

err:
printk("%s: Error resetting SDIO communications (%d)\n",
mmc_hostname(host), err);
mmc_release_host(host);
return err;
}
EXPORT_SYMBOL(sdio_reset_comm);
37 changes: 37 additions & 0 deletions drivers/mmc/host/sdhci-s3c.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,29 @@ static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
platform_get_device_id(pdev)->driver_data;
}

static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
{
struct sdhci_host *host = platform_get_drvdata(dev);
unsigned long flags;

if (host) {
spin_lock_irqsave(&host->lock, flags);
if (state) {
dev_dbg(&dev->dev, "card inserted.\n");
pr_info("%s: card inserted.\n",
mmc_hostname(host->mmc));
host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
} else {
dev_dbg(&dev->dev, "card removed.\n");
pr_info("%s: card removed.\n",
mmc_hostname(host->mmc));
host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
}
spin_unlock_irqrestore(&host->lock, flags);
mmc_detect_change(host->mmc, msecs_to_jiffies(200));
}
}

static int sdhci_s3c_probe(struct platform_device *pdev)
{
struct s3c_sdhci_platdata *pdata;
Expand Down Expand Up @@ -623,6 +646,9 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
if (pdata->host_caps2)
host->mmc->caps2 |= pdata->host_caps2;

if (pdata->pm_flags)
host->mmc->pm_flags |= pdata->pm_flags;

pm_runtime_enable(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
pm_runtime_use_autosuspend(&pdev->dev);
Expand All @@ -638,6 +664,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
goto err_req_regs;
}

/* The following two methods of card detection might call
sdhci_s3c_notify_change() immediately, so they can be called
only after sdhci_add_host(). Setup errors are ignored. */
if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init) {
pdata->ext_cd_init(&sdhci_s3c_notify_change);
}

#ifdef CONFIG_PM
if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
clk_disable_unprepare(sc->clk_io);
Expand All @@ -658,9 +691,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev)

static int sdhci_s3c_remove(struct platform_device *pdev)
{
struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data;
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_s3c *sc = sdhci_priv(host);

if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup)
pdata->ext_cd_cleanup(&sdhci_s3c_notify_change);

if (sc->ext_cd_irq)
free_irq(sc->ext_cd_irq, sc);

Expand Down
5 changes: 5 additions & 0 deletions drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,11 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
timeout = jiffies;
if (!cmd->data && cmd->busy_timeout > 9000)
timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
#if defined(CONFIG_BCMDHD)
/* HACK: use short timeout */
else if (cmd->opcode == SD_IO_RW_EXTENDED)
timeout += msecs_to_jiffies(500);
#endif
else
timeout += 10 * HZ;
mod_timer(&host->timer, timeout);
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ config USB_NET_RNDIS_WLAN

If you choose to build a module, it'll be called rndis_wlan.

source "drivers/net/wireless/bcm4336/Kconfig"

endif # WLAN
11 changes: 11 additions & 0 deletions drivers/net/wireless/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ obj-$(CONFIG_PCMCIA_WL3501) += wl3501_cs.o
obj-$(CONFIG_USB_NET_RNDIS_WLAN) += rndis_wlan.o

obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o

obj-$(CONFIG_WL_TI) += ti/

obj-$(CONFIG_MWIFIEX) += mwifiex/

obj-$(CONFIG_BCMDHD) += bcm4336/
obj-$(CONFIG_BRCMFMAC) += brcm80211/
obj-$(CONFIG_BRCMSMAC) += brcm80211/

obj-$(CONFIG_CW1200) += cw1200/
obj-$(CONFIG_RSI_91X) += rsi/
52 changes: 52 additions & 0 deletions drivers/net/wireless/bcm4336/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
config BCMDHD
tristate "Broadcom FullMAC wireless cards support"
---help---
This module adds support for wireless adapters based on
Broadcom FullMAC chipset.

config BCMDHD_FW_PATH
depends on BCMDHD
string "Firmware path"
default "/system/etc/firmware/fw_bcmdhd.bin"
---help---
Path to the firmware file.

config BCMDHD_NVRAM_PATH
depends on BCMDHD
string "NVRAM path"
default "/system/etc/firmware/nvram.txt"
---help---
Path to the calibration file.

config BCMDHD_CONFIG_PATH
depends on BCMDHD
string "Config path"
default "/system/etc/firmware/config.txt"
---help---
Path to the driver configuration file.

config BCMDHD_WEXT
bool "Enable WEXT support"
depends on BCMDHD && CFG80211 = n
select WIRELESS_EXT
select WEXT_PRIV
help
Enables WEXT support

choice
depends on BCMDHD
prompt "Interrupt type"
default BCMDHD_OOB
---help---
Interrupt type
config BCMDHD_OOB
depends on BCMDHD
bool "Out-of-Band Interrupt"
---help---
Interrupt from WL_HOST_WAKE.
config BCMDHD_SDIO_IRQ
depends on BCMDHD
bool "In-Band Interrupt"
---help---
Interrupt from SDIO DAT[1]
endchoice
Loading