diff --git a/meta-digi-arm/conf/machine/cpx2.conf b/meta-digi-arm/conf/machine/cpx2.conf index 7967fb1a8..8a481b085 100644 --- a/meta-digi-arm/conf/machine/cpx2.conf +++ b/meta-digi-arm/conf/machine/cpx2.conf @@ -27,3 +27,4 @@ WPA_DRIVER = "nl80211" MACHINE_FIRMWARE = "firmware-mxs-ar3k" MACHINE_EXTRA_RRECOMMENDS += "${MACHINE_FIRMWARE}" +# MACHINE_FEATURES_append = " wifi" diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/files/atheros b/meta-digi-arm/recipes-kernel/kernel-module-atheros/ccardimx28js/atheros similarity index 100% rename from meta-digi-arm/recipes-kernel/kernel-module-atheros/files/atheros rename to meta-digi-arm/recipes-kernel/kernel-module-atheros/ccardimx28js/atheros diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/cpx2/atheros b/meta-digi-arm/recipes-kernel/kernel-module-atheros/cpx2/atheros new file mode 100644 index 000000000..cbeea1a39 --- /dev/null +++ b/meta-digi-arm/recipes-kernel/kernel-module-atheros/cpx2/atheros @@ -0,0 +1,90 @@ +#!/bin/sh +#=============================================================================== +# +# 10-atheros_pre-up +# +# Copyright (C) 2012 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: Load Atheros' wireless driver +# +#=============================================================================== + +set -e + +[ "${IFACE}" != "wlan0" ] && exit 0 + +FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1" +RAM_DRIVE="/var/run" +MAC_FILENAME="softmac" + +# +# Get the wlan MAC address from kernel command line. Use a default +# value if the address has not been set. +# +MAC_ADDR="$(sed -e 's,.\+ethaddr2=\([^[:blank:]]\+\)[[:blank:]].*,\1,g' /proc/cmdline)" +if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then + MAC_ADDR="00:04:F3:4C:B1:D3" +fi + +mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)" +mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)" +mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)" +mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)" +mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)" +mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)" + +printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${RAM_DRIVE}/${MAC_FILENAME} + +# We need to write the WLAN MAC address to softmac in the ath6k firmware +# directory. However, we don't want to rewrite the file if it already exists +# and the address is the same because we don't want to wear out NAND flash. +# +# So create the file on the RAM DRIVE first and compare the two. Only update +# the copy on NAND if the address has changed. +# +if ! cmp -s ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME}; then + cp ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME} +fi +rm -f ${RAM_DRIVE}/${MAC_FILENAME} + +if [ -e "/sys/kernel/machine/name" ]; then + MACHINE="$(cat /sys/kernel/machine/name)" + # Figure out which wireless region we are in. The US has rules for + # what channels can be used and at what power level. We use a different set of + # rules for the other regions in the world that we sell into. The mod_cert field + # in OTP will be set to 0x0 for the US. Once we know the region, make sure the + # appropriate calibration file is loaded. + # + US_CODE="0x0" + REGION_CODE="$(cat /sys/kernel/${MACHINE}/mod_cert)" + if [ -z "${REGION_CODE}" -o "${US_CODE}" = "${REGION_CODE}" ]; then + BDATA_SOURCE=calData_AR6103_Digi_X2e_B.bin + else + BDATA_SOURCE=calData_AR6103_Digi_X2e_B_world.bin + fi +else + echo "Undefined machine, defaulting to world region." + BDATA_SOURCE=calData_AR6103_Digi_X2e_B_world.bin +fi + +# We don't want to rewrite NAND every time we boot so only +# change the link if it is wrong. +BDATA_LINK="${FIRMWARE_DIR}/bdata.bin" +if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${FIRMWARE_DIR}/${BDATA_SOURCE}"; then + ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" +fi + +# ath6kl_sdio.ko +ATH6KL_PARAMS="ath6kl_p2p=1 softmac_enable=1" +[ -f "/root/wifi_test_mode" ] && { ATH6KL_PARAMS="${ATH6KL_PARAMS} testmode=1"; test_mode_str=" in test mode"; } +grep -qs ath6kl_sdio /proc/modules || \ + modprobe --ignore-install -q ath6kl_sdio ${ATH6KL_PARAMS} || echo "Loading ath6kl_sdio module${test_mode_str}: [FAILED]" + +# Delay required for the interface 'wlan0' to settle down before trying to configure it. +sleep 0.5 diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb index 06a8845e8..5ce32f7e8 100644 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb +++ b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb @@ -21,6 +21,7 @@ TARBALL_SHA256 = "66396f801b6d4254370d81ebaa34f963207dfcf2f9ce4ec72a86f11906ec9b SRC_URI_git = "${DIGI_LOG_GIT}linux-modules/atheros.git;protocol=git" SRC_URI_tar = "${DIGI_MIRROR}/atheros-${SRCREV_SHORT}.tar.gz;md5sum=${TARBALL_MD5};sha256sum=${TARBALL_SHA256}" +FILESEXTRAPATHS_prepend := "${THISDIR}/${MACHINE}:" SRC_URI = "${@base_conditional('ATHEROS_BUILD_FROM_GIT', '1' , '${SRC_URI_git}', '${SRC_URI_tar}', d)}" SRC_URI += " \ file://atheros \ diff --git a/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/config-wireless-atheros.cfg b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/config-wireless-atheros.cfg new file mode 100644 index 000000000..87bc0b4cb --- /dev/null +++ b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/config-wireless-atheros.cfg @@ -0,0 +1,8 @@ +CONFIG_WLAN=y +CONFIG_WIRELESS=y +CONFIG_WIRELESS_EXT=y +CONFIG_WEXT_CORE=y +CONFIG_WEXT_PROC=y +CONFIG_RFKILL=y +CONFIG_RFKILL_INPUT=y + diff --git a/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2-Remove-incorrect-pin-configurations.patch b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2-Remove-incorrect-pin-configurations.patch new file mode 100644 index 000000000..01e5384bc --- /dev/null +++ b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2-Remove-incorrect-pin-configurations.patch @@ -0,0 +1,37 @@ +From a4ad7a68fa1d203314b71436b5911f2189aafb91 Mon Sep 17 00:00:00 2001 +From: Alex Gonzalez +Date: Thu, 16 May 2013 10:30:20 +0200 +Subject: [PATCH 1/2] cpx2: Remove incorrect pin configurations. + +The CPX2e does not use the PINID_SAIF0_LRCLK pin to power up the wifi. + +Signed-off-by: Alex Gonzalez +--- + arch/arm/mach-mx28/mx28_cpx2_pins.c | 14 -------------- + 1 file changed, 14 deletions(-) + +diff --git a/arch/arm/mach-mx28/mx28_cpx2_pins.c b/arch/arm/mach-mx28/mx28_cpx2_pins.c +index e7d6507..07c65bf 100755 +--- a/arch/arm/mach-mx28/mx28_cpx2_pins.c ++++ b/arch/arm/mach-mx28/mx28_cpx2_pins.c +@@ -51,20 +51,6 @@ static struct pin_desc mx28_cpx2_fixed_pins[] = { + .id = PINID_PWM1, + .fun = PIN_GPIO, + }, +-#ifdef CONFIG_WLAN +- { +- .name = "ATHEROS_PWR", +- .id = PINID_SAIF0_LRCLK, +- .fun = PIN_GPIO, +- .strength = PAD_4MA, +- .voltage = PAD_3_3V, +- .pullup = 0, +- .drive = 1, +- .pull = 0, +- .output = 1, +- .data = 1, +- }, +-#endif + #ifdef CONFIG_MXS_AUART0_DEVICE_ENABLE + { + .name = "AUART0.RX", diff --git a/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2e-Setup-mmc0-for-the-wireless-interface.patch b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2e-Setup-mmc0-for-the-wireless-interface.patch new file mode 100644 index 000000000..85e6c5690 --- /dev/null +++ b/meta-digi-arm/recipes-kernel/linux/linux-del-2.6.35.14/cpx2/cpx2e-Setup-mmc0-for-the-wireless-interface.patch @@ -0,0 +1,133 @@ +From 4b17f5ce43df8b18c977386081d57929470e6bba Mon Sep 17 00:00:00 2001 +From: Alex Gonzalez +Date: Thu, 16 May 2013 10:31:24 +0200 +Subject: [PATCH 2/2] cpx2e: Setup mmc0 for the wireless interface. + +The Atheros wireless chip is connected via SDIO to mmc0. This commits +sets up the interface ready to be used. + +Signed-off-by: Alex Gonzalez +--- + arch/arm/mach-mx28/device.c | 102 ++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 101 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/mach-mx28/device.c b/arch/arm/mach-mx28/device.c +index ca0739c..1475b28 100755 +--- a/arch/arm/mach-mx28/device.c ++++ b/arch/arm/mach-mx28/device.c +@@ -398,7 +398,7 @@ static void mx28_init_gpmi_nfc(void) + #endif + + #if defined(CONFIG_MMC_MXS) || defined(CONFIG_MMC_MXS_MODULE) +-#if defined(CONFIG_MACH_MX28EVK) || defined (CONFIG_MACH_CPX2) || defined (CONFIG_MACH_WR21) ++#if defined(CONFIG_MACH_MX28EVK) || defined (CONFIG_MACH_WR21) + #define MMC0_POWER MXS_PIN_TO_GPIO(PINID_PWM3) + #define MMC1_POWER MXS_PIN_TO_GPIO(PINID_PWM4) + #define MMC0_WP MXS_PIN_TO_GPIO(PINID_SSP1_SCK) +@@ -629,6 +629,106 @@ static void __init mx28_init_mmc(void) + mxs_add_device(pdev, 2); + } + } ++#elif defined (CONFIG_MACH_CPX2) ++#define MMC0_POWER MXS_PIN_TO_GPIO(PINID_AUART1_TX) ++ ++static int mxs_mmc_hw_init_ssp0(void) ++{ ++ int ret = 0; ++ ++ /* Configure POWER pin as gpio to drive power to MMC slot */ ++ ret = gpio_request(MMC0_POWER, "mmc0_power"); ++ if (ret) ++ goto out_power; ++ ++ gpio_direction_output(MMC0_POWER, 1); ++ mdelay(100); ++ ++ return 0; ++ ++out_power: ++ return ret; ++} ++ ++static void mxs_mmc_hw_release_ssp0(void) ++{ ++ gpio_free(MMC0_POWER); ++} ++ ++static void mxs_mmc_cmd_pullup_ssp0(int enable) ++{ ++ mxs_set_pullup(PINID_SSP0_CMD, enable, 0 /* sysfs */, "mmc0_cmd"); ++} ++ ++static unsigned long mxs_mmc_setclock_ssp0(unsigned long hz) ++{ ++ struct clk *ssp = clk_get(NULL, "ssp.0"), *parent; ++ if (hz > 1000000) ++ parent = clk_get(NULL, "ref_io.0"); ++ else ++ parent = clk_get(NULL, "xtal.0"); ++ ++ clk_set_parent(ssp, parent); ++ clk_set_rate(ssp, 2 * hz); ++ clk_put(parent); ++ clk_put(ssp); ++ ++ return hz; ++} ++ ++static struct mxs_mmc_platform_data mmc0_data = { ++ .hw_init = mxs_mmc_hw_init_ssp0, ++ .hw_release = mxs_mmc_hw_release_ssp0, ++ .get_wp = NULL, ++ .cmd_pullup = mxs_mmc_cmd_pullup_ssp0, ++ .setclock = mxs_mmc_setclock_ssp0, ++ .caps = MMC_CAP_4_BIT_DATA ++ | MMC_CAP_DATA_DDR, ++ .min_clk = 400000, ++ .max_clk = 48000000, ++ .read_uA = 50000, ++ .write_uA = 70000, ++ .clock_mmc = "ssp.0", ++ .power_mmc = NULL, ++}; ++ ++static struct resource mmc0_resource[] = { ++ { ++ .flags = IORESOURCE_MEM, ++ .start = SSP0_PHYS_ADDR, ++ .end = SSP0_PHYS_ADDR + 0x2000 - 1, ++ }, ++ { ++ .flags = IORESOURCE_DMA, ++ .start = MXS_DMA_CHANNEL_AHB_APBH_SSP0, ++ .end = MXS_DMA_CHANNEL_AHB_APBH_SSP0, ++ }, ++ { ++ .flags = IORESOURCE_IRQ, ++ .start = IRQ_SSP0_DMA, ++ .end = IRQ_SSP0_DMA, ++ }, ++ { ++ .flags = IORESOURCE_IRQ, ++ .start = IRQ_SSP0, ++ .end = IRQ_SSP0, ++ }, ++}; ++ ++static void __init mx28_init_mmc(void) ++{ ++ struct platform_device *pdev; ++ ++ if (mxs_get_type(PINID_SSP0_CMD) == PIN_FUN1) { ++ pdev = mxs_get_device("mxs-mmc", 0); ++ if (pdev == NULL || IS_ERR(pdev)) ++ return; ++ pdev->resource = mmc0_resource; ++ pdev->num_resources = ARRAY_SIZE(mmc0_resource); ++ pdev->dev.platform_data = &mmc0_data; ++ mxs_add_device(pdev, 0); ++ } ++} + #elif defined(CONFIG_MACH_CCARDIMX28JS) + #define MMC2_POWER MXS_PIN_TO_GPIO(PINID_SSP2_MISO) + #define MMC2_WP /* This is the Wi-Fi interface so there is no write protect*/ diff --git a/meta-digi-arm/recipes-kernel/linux/linux-del_2.6.35.14.bb b/meta-digi-arm/recipes-kernel/linux/linux-del_2.6.35.14.bb index 36c8f54ea..1330b9eb0 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-del_2.6.35.14.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-del_2.6.35.14.bb @@ -46,6 +46,11 @@ SRC_URI += " \ ${KERNEL_CFG_FRAGS} \ " +SRC_URI_append_cpx2 = " \ + file://cpx2-Remove-incorrect-pin-configurations.patch \ + file://cpx2e-Setup-mmc0-for-the-wireless-interface.patch \ + " + S = "${@base_conditional('KERNEL_BUILD_SRC', '1' , '${WORKDIR}/git', '${WORKDIR}/linux-2.6-${SRCREV_SHORT}', d)}" SCMVERSION = "${@base_conditional('KERNEL_BUILD_SRC', '1' , '1', '0', d)}"