diff options
author | Sheshagiri Shenoy <sshenoy@nvidia.com> | 2011-04-18 15:38:01 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:46:27 -0800 |
commit | 2280d866884faaa013f8f906153a705ef7c42a87 (patch) | |
tree | 2304dc5e12a849f2d9ec45204e9c862264cf8f11 | |
parent | d3f4d0c342c890a46ff9841e2356f9db85ed7617 (diff) |
ARM: tegra: whistler: enable spi-slave based modem.
- configured the pinmuxes needed by the baseband.
- added board specific baseband related code.
- added caif specific platform data needed by protocol layer.
bug 785523
Change-Id: I2d1936419ccd9190d6539836cb8bca563ea07c6e
Reviewed-on: http://git-master/r/23432
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Rebase-Id: R88b62bdca3f984c66510158d1bc6878fdd014619
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-baseband.c | 228 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-baseband.h | 73 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-pinmux.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-whistler.c | 4 |
4 files changed, 261 insertions, 50 deletions
diff --git a/arch/arm/mach-tegra/board-whistler-baseband.c b/arch/arm/mach-tegra/board-whistler-baseband.c index 43b216b5f9a7..25721965705e 100644 --- a/arch/arm/mach-tegra/board-whistler-baseband.c +++ b/arch/arm/mach-tegra/board-whistler-baseband.c @@ -1,49 +1,189 @@ /* * arch/arm/mach-tegra/board-whistler-baseband.c * - * Copyright (c) 2011, NVIDIA Corporation. + * Copyright (C) 2011 NVIDIA Corporation * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <linux/resource.h> -#include <linux/platform_device.h> -#include <linux/delay.h> -#include <linux/gpio.h> -#include <linux/err.h> -#include <linux/platform_data/tegra_usb.h> -#include <asm/mach-types.h> -#include <asm/mach/arch.h> -#include <mach/pinmux.h> -#include <mach/usb_phy.h> - -#include "devices.h" -#include "gpio-names.h" - -#define MODEM_PWR_ON TEGRA_GPIO_PV1 -#define MODEM_RESET TEGRA_GPIO_PV0 - -/* Rainbow1 and 570 */ -#define AWR TEGRA_GPIO_PZ0 -#define CWR TEGRA_GPIO_PY6 -#define SPI_INT TEGRA_GPIO_PO6 -#define SPI_SLAVE_SEL TEGRA_GPIO_PV2 - -/* PH450 */ -#define AP2MDM_ACK2 TEGRA_GPIO_PU2 -#define MDM2AP_ACK2 TEGRA_GPIO_PV2 +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/tegra_caif.h> +#include "board-whistler-baseband.h" + +unsigned long baseband_type = BOARD_WHISTLER_BASEBAND_U3XX; + +module_param(baseband_type, ulong, 0644); +MODULE_PARM_DESC(baseband_type, "baseband type"); + +static struct tegra_clk_init_table u3xx_clk[] = { + /* spi slave controller clock @ 4 x 13 Mhz interface clock */ + { "sbc1", "pll_m", 52000000, true}, + { NULL, NULL, 0, 0}, +}; + +static struct tegra_clk_init_table n731_clk[] = { + /* spi master controller clock @ 4 x 12 Mhz interface clock */ + { "sbc1", "pll_m", 48000000, true}, + { NULL, NULL, 0, 0}, +}; + +static struct tegra_clk_init_table spi_loopback_clk[] = { + /* spi slave / master controller clocks @ 4 x max interface clock */ + { "sbc1", "pll_m", 60000000, true}, + { "sbc2", "pll_m", 60000000, true}, + { NULL, NULL, 0, 0}, +}; + +static struct tegra_clk_init_table hsic_clk[] = { + { NULL, NULL, 0, 0}, +}; + +static struct platform_device *u3xx_device[] = { + /* spi slave */ + &tegra_spi_slave_device1, +}; + +static struct platform_device *n731_device[] = { + /* spi master */ + &tegra_spi_device1, +}; + +static struct platform_device *spi_loopback_device[] = { + /* spi slave / master */ + &tegra_spi_slave_device1, + &tegra_spi_device2, +}; + +static struct platform_device *hsic_device[] = { +}; + +struct tegra_caif_platform_data tegra_whistler_u3xx_plat_data = { + .reset = TEGRA_CAIF_SSPI_GPIO_RESET, + .power = TEGRA_CAIF_SSPI_GPIO_POWER, + .awr = TEGRA_CAIF_SSPI_GPIO_AWR, + .cwr = TEGRA_CAIF_SSPI_GPIO_CWR, + .spi_int = TEGRA_CAIF_SSPI_GPIO_SPI_INT, + .spi_ss = TEGRA_CAIF_SSPI_GPIO_SS, +}; + +static struct spi_board_info u3xx_spi_board_info[] = { + /* spi slave */ + { + .modalias = "baseband_spi_slave0.0", + .bus_num = 0, + .chip_select = 0, + .mode = SPI_MODE_0, + .max_speed_hz = 52000000, + .platform_data = &tegra_whistler_u3xx_plat_data, + .irq = 0, + }, +}; + +static struct spi_board_info n731_spi_board_info[] = { + /* spi master */ + { + .modalias = "spi_ipc", + .bus_num = 0, + .chip_select = 0, + .mode = SPI_MODE_1, + .max_speed_hz = 12000000, + .platform_data = NULL, + .irq = 0, + }, +}; + +static struct spi_board_info spi_loopback_spi_board_info[] = { + /* spi slave <---> spi master */ + { + .modalias = "baseband_loopback", + .bus_num = 0, + .chip_select = 0, + .mode = SPI_MODE_0, + .max_speed_hz = 13000000, + .platform_data = &tegra_whistler_u3xx_plat_data, + .irq = 0, + }, + { + .modalias = "baseband_spi_master1.1", + .bus_num = 1, + .chip_select = 1, + .mode = SPI_MODE_0, + .max_speed_hz = 13000000, + .platform_data = NULL, + .irq = 0, + }, +}; + +static struct whistler_baseband whistler_baseband[] = { + [BOARD_WHISTLER_BASEBAND_U3XX] = { + .clk_init = u3xx_clk, + .platform_device = u3xx_device, + .platform_device_size = ARRAY_SIZE(u3xx_device), + .spi_board_info = u3xx_spi_board_info, + .spi_board_info_size = ARRAY_SIZE(u3xx_spi_board_info), + }, + [BOARD_WHISTLER_BASEBAND_N731] = { + .clk_init = n731_clk, + .platform_device = n731_device, + .platform_device_size = ARRAY_SIZE(n731_device), + .spi_board_info = n731_spi_board_info, + .spi_board_info_size = ARRAY_SIZE(n731_spi_board_info), + }, + [BOARD_WHISTLER_BASEBAND_SPI_LOOPBACK] = { + .clk_init = spi_loopback_clk, + .platform_device = spi_loopback_device, + .platform_device_size = ARRAY_SIZE(spi_loopback_device), + .spi_board_info = spi_loopback_spi_board_info, + .spi_board_info_size = ARRAY_SIZE(spi_loopback_spi_board_info), + }, + [BOARD_WHISTLER_BASEBAND_HSIC] = { + .clk_init = hsic_clk, + .platform_device = hsic_device, + .platform_device_size = ARRAY_SIZE(hsic_device), + }, +}; + +int whistler_baseband_init(void) +{ + int idx; + int err; + idx = baseband_type; + + if (whistler_baseband[idx].clk_init) + tegra_clk_init_from_table(whistler_baseband[idx].clk_init); + + if (whistler_baseband[idx].platform_device_size) + platform_add_devices(whistler_baseband[idx].platform_device, + whistler_baseband[idx].platform_device_size); + + if (whistler_baseband[idx].spi_board_info_size) { + err = spi_register_board_info( + whistler_baseband[idx].spi_board_info, + whistler_baseband[idx].spi_board_info_size); + if (err < 0) + pr_err("%s: spi_register_board returned error %d\n", + __func__, err); + } + + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_RESET); + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_POWER); + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_AWR); + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_CWR); + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_SPI_INT); + tegra_gpio_enable(TEGRA_CAIF_SSPI_GPIO_SS); + return 0; +} static int rainbow_570_reset(void); static int rainbow_570_handshake(void); @@ -209,14 +349,11 @@ static int ph450_reset(void) while (retry) { /* wait for MDM2AP_ACK2 low */ int val = gpio_get_value(MDM2AP_ACK2); - if (!val) { - printk("MDM2AP_ACK2 detected\n"); - return 0; - } else { - printk("."); + if (!val) + break; + else retry--; mdelay(100); - } } return 1; @@ -230,7 +367,7 @@ static int ph450_handshake(void) return 0; } -int __init whistler_baseband_init(void) +int __init whistler_baseband_ph450_init(void) { int ret; @@ -244,6 +381,5 @@ int __init whistler_baseband_init(void) } tegra_null_ulpi_init(); - return 0; } diff --git a/arch/arm/mach-tegra/board-whistler-baseband.h b/arch/arm/mach-tegra/board-whistler-baseband.h new file mode 100644 index 000000000000..c8f561669468 --- /dev/null +++ b/arch/arm/mach-tegra/board-whistler-baseband.h @@ -0,0 +1,73 @@ +/* + * arch/arm/mach-tegra/board-whistler-baseband.h + * + * Copyright (C) 2011 NVIDIA Corporation + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef BOARD_WHISTLER_BASEBAND_H +#define BOARD_WHISTLER_BASEBAND_H + +#include <linux/delay.h> +#include <linux/gpio.h> +#include <linux/spi/spi.h> +#include <linux/platform_data/tegra_usb.h> +#include <mach/usb_phy.h> +#include <linux/resource.h> +#include <linux/platform_device.h> +#include <linux/err.h> +#include <asm/mach-types.h> +#include <mach/pinmux.h> +#include <mach/spi.h> + +#include "clock.h" +#include "devices.h" +#include "gpio-names.h" + +#define BOARD_WHISTLER_BASEBAND_U3XX 0 +#define BOARD_WHISTLER_BASEBAND_N731 1 +#define BOARD_WHISTLER_BASEBAND_SPI_LOOPBACK 2 +#define BOARD_WHISTLER_BASEBAND_HSIC 3 + +#define TEGRA_CAIF_SSPI_GPIO_RESET TEGRA_GPIO_PV0 +#define TEGRA_CAIF_SSPI_GPIO_POWER TEGRA_GPIO_PV1 +#define TEGRA_CAIF_SSPI_GPIO_AWR TEGRA_GPIO_PZ0 +#define TEGRA_CAIF_SSPI_GPIO_CWR TEGRA_GPIO_PY6 +#define TEGRA_CAIF_SSPI_GPIO_SPI_INT TEGRA_GPIO_PO6 +#define TEGRA_CAIF_SSPI_GPIO_SS TEGRA_GPIO_PV2 + +#define MODEM_PWR_ON TEGRA_GPIO_PV1 +#define MODEM_RESET TEGRA_GPIO_PV0 + +/* Rainbow1 and 570 */ +#define AWR TEGRA_GPIO_PZ0 +#define CWR TEGRA_GPIO_PY6 +#define SPI_INT TEGRA_GPIO_PO6 +#define SPI_SLAVE_SEL TEGRA_GPIO_PV2 + +/* PH450 */ +#define AP2MDM_ACK2 TEGRA_GPIO_PU2 +#define MDM2AP_ACK2 TEGRA_GPIO_PV2 + + +struct whistler_baseband { + struct tegra_clk_init_table *clk_init; + struct platform_device **platform_device; + int platform_device_size; + struct spi_board_info *spi_board_info; + int spi_board_info_size; +}; + +int whistler_baseband_init(void); + +#endif /* BOARD_WHISTLER_BASEBAND_H */ + diff --git a/arch/arm/mach-tegra/board-whistler-pinmux.c b/arch/arm/mach-tegra/board-whistler-pinmux.c index d2e1de48b70a..aa74f29a9624 100644 --- a/arch/arm/mach-tegra/board-whistler-pinmux.c +++ b/arch/arm/mach-tegra/board-whistler-pinmux.c @@ -1,7 +1,7 @@ /* * arch/arm/mach-tegra/board-whistler-pinmux.c * - * Copyright (C) 2010 NVIDIA Corporation + * Copyright (C) 2010-2011 NVIDIA Corporation * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -125,7 +125,7 @@ static __initdata struct tegra_pingroup_config whistler_pinmux[] = { {TEGRA_PINGROUP_SDB, TEGRA_MUX_SDIO3, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_SDC, TEGRA_MUX_SDIO3, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_SDD, TEGRA_MUX_SDIO3, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, - {TEGRA_PINGROUP_SDIO1, TEGRA_MUX_RSVD2, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, + {TEGRA_PINGROUP_SDIO1, TEGRA_MUX_RSVD1, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_SLXA, TEGRA_MUX_SDIO3, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_SLXC, TEGRA_MUX_SDIO3, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_SLXD, TEGRA_MUX_SDIO3, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, @@ -142,7 +142,7 @@ static __initdata struct tegra_pingroup_config whistler_pinmux[] = { {TEGRA_PINGROUP_SPIH, TEGRA_MUX_SPI2_ALT, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_UAA, TEGRA_MUX_UARTA, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_UAB, TEGRA_MUX_UARTA, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, - {TEGRA_PINGROUP_UAC, TEGRA_MUX_OWR, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, + {TEGRA_PINGROUP_UAC, TEGRA_MUX_OWR, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_UAD, TEGRA_MUX_IRDA, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_UCA, TEGRA_MUX_UARTC, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, {TEGRA_PINGROUP_UCB, TEGRA_MUX_UARTC, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, diff --git a/arch/arm/mach-tegra/board-whistler.c b/arch/arm/mach-tegra/board-whistler.c index f2d3842a8f67..9379353c1234 100644 --- a/arch/arm/mach-tegra/board-whistler.c +++ b/arch/arm/mach-tegra/board-whistler.c @@ -54,6 +54,7 @@ #include "devices.h" #include "gpio-names.h" #include "fuse.h" +#include "board-whistler-baseband.h" static struct plat_serial8250_port debug_uart_platform_data[] = { { @@ -363,7 +364,7 @@ static void whistler_usb_init(void) tegra_otg_device.dev.platform_data = &tegra_otg_pdata; platform_device_register(&tegra_otg_device); - tegra_ehci3_device.dev.platform_data=&tegra_ehci_pdata[2]; + tegra_ehci3_device.dev.platform_data = &tegra_ehci_pdata[2]; platform_device_register(&tegra_ehci3_device); } @@ -392,6 +393,7 @@ static void __init tegra_whistler_init(void) whistler_scroll_init(); whistler_power_off_init(); whistler_emc_init(); + whistler_baseband_init(); } int __init tegra_whistler_protected_aperture_init(void) |