ARN: MX3: modularize 'mx31lite' code
Subsystems (3)
PATCH 1/5 ARN: MX3: modularize 'mx31lite' code
This commit splits the support code for LogicPD's mx31lite hardware into module and board specific parts.
This introduces a new mandatory coreparam called 'mx31lite_baseboard' which specifies the base board support to use. For now, only the LiteKit development board is supported, and developers of own boards are encouraged to use that as reference.
The UART support moved to the board code.
Some comments were amended along the way.
--- arch/arm/mach-mx3/Makefile | 2 +- arch/arm/mach-mx3/mx31lite-db.c | 71 +++++++++++++++++++++++ arch/arm/mach-mx3/mx31lite.c | 36 +++++------ arch/arm/plat-mxc/include/mach/board-mx31lite.h | 39 +++++++++++-- 4 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 arch/arm/mach-mx3/mx31lite-db.c
arch/arm/mach-mx3/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_ARCH_MX31) += clock.o iomux.o obj-$(CONFIG_ARCH_MX35) += clock-imx35.o obj-$(CONFIG_MACH_MX31ADS) += mx31ads.o obj-$(CONFIG_MACH_MX31LILLY) += mx31lilly.o mx31lilly-db.o -obj-$(CONFIG_MACH_MX31LITE) += mx31lite.o +obj-$(CONFIG_MACH_MX31LITE) += mx31lite.o mx31lite-db.o obj-$(CONFIG_MACH_PCM037) += pcm037.o obj-$(CONFIG_MACH_PCM037_EET) += pcm037_eet.o obj-$(CONFIG_MACH_MX31_3DS) += mx31pdk.o
arch/arm/mach-mx3/mx31lite-db.c new file +71 -0
71 lines not on this page · raw message
arch/arm/mach-mx3/mx31lite.c +16 -20
@@ -42,23 +42,14 @@#include "devices.h" /* -* This file contains the board-specific initialization routines. +* This file contains the module-specific initialization routines. */ static unsigned int mx31lite_pins[] = { -/* UART1 */ -MX31_PIN_CTS1__CTS1 , -MX31_PIN_RTS1__RTS1 , -MX31_PIN_TXD1__TXD1 , -MX31_PIN_RXD1__RXD1 ,/* LAN9117 IRQ pin */ IOMUX_MODE (MX31_PIN_SFS6 ,IOMUX_CONFIG_GPIO ), }; -static struct imxuart_platform_data uart_pdata = { - .flags =IMXUART_HAVE_RTSCTS , -}; -static struct mxc_nand_platform_data mx31lite_nand_board_info = { .width =1 , .hw_ecc =1 ,
@@ -118,17 +109,27 @@ void __init mx31lite_map_io(void)iotable_init (mx31lite_io_desc,ARRAY_SIZE (mx31lite_io_desc)); } -/* -* Board specific initialization. -*/ +static int mx31lite_baseboard; +core_param (mx31lite_baseboard, mx31lite_baseboard, int,0444 ); +static void __init mxc_board_init (void ) {int ret; +switch (mx31lite_baseboard) { +case MX31LITE_NOBOARD : +break ; +case MX31LITE_DB : +mx31lite_db_init (); +break ; +default : +printk (KERN_ERR "Illegal mx31lite_baseboard type %d\n" , + mx31lite_baseboard); + } +mxc_iomux_setup_multiple_pins (mx31lite_pins,ARRAY_SIZE (mx31lite_pins),"mx31lite" ); -mxc_register_device (&mxc_uart_device0, &uart_pdata);mxc_register_device (&mxc_nand_device, &mx31lite_nand_board_info);/* SMSC9117 IRQ pin */
@@ -150,12 +151,7 @@ struct sys_timer mx31lite_timer = { .init = mx31lite_timer_init, }; -/* -* The following uses standard kernel macros defined in arch.h in order to -* initialize __mach_desc_MX31LITE data structure. -*/ - -MACHINE_START (MX31LITE ,"LogicPD MX31 LITEKIT" ) +MACHINE_START (MX31LITE ,"LogicPD i.MX31 SOM" )/* Maintainer: Freescale Semiconductor, Inc. */ .phys_io = AIPS1_BASE_ADDR, .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
arch/arm/plat-mxc/include/mach/board-mx31lite.h +33 -6
@@ -1,15 +1,42 @@/* * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2009 Daniel Mack <[email protected]> +* +* Based on code for mobots boards, +* Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group +* +* 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 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. */ +#ifndef __ASM_ARCH_MXC_BOARD_MX31LITE_H__ +#define __ASM_ARCH_MXC_BOARD_MX31LITE_H__ + +#ifndef __ASSEMBLY__ + +enum mx31lilly_boards { +MX31LITE_NOBOARD =0 , +MX31LITE_DB =1 , +}; +/* -* 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. +* This CPU module needs a baseboard to work. After basic initializing +* its own devices, it calls baseboard's init function. */ -#ifndef __ASM_ARCH_MXC_BOARD_MX31LITE_H__ -#define __ASM_ARCH_MXC_BOARD_MX31LITE_H__ +extern void mx31lite_db_init (void ); -#endif /* __ASM_ARCH_MXC_BOARD_MX31LITE_H__ */ +#endif +#endif /* __ASM_ARCH_MXC_BOARD_MX31LITE_H__ */
Signature · 1 line
1.6.5.2
PATCH 2/5 ARM: MX3: add MMC/SDHC support to mx31lite-db.c
--- arch/arm/mach-mx3/mx31lite-db.c | 70 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +70 -0
@@ -38,6 +38,7 @@#include <mach/imx-uart.h> #include <mach/iomux-mx3.h> #include <mach/board-mx31lite.h> +#include <mach/mmc.h> #include "devices.h"
@@ -61,11 +62,80 @@ static struct imxuart_platform_data uart_pdata __initdata = { .flags = IMXUART_HAVE_RTSCTS, }; +/* MMC */ + +static int gpio_det, gpio_wp; + +#define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ + PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) + +static int mxc_mmc1_get_ro (struct device *dev) +{ +return gpio_get_value (IOMUX_TO_GPIO (MX31_PIN_LCS0 )); +} + +static int mxc_mmc1_init (struct device *dev, +irq_handler_t detect_irq,void *data) +{ +int ret; + + gpio_det =IOMUX_TO_GPIO (MX31_PIN_DCD_DCE1 ); + gpio_wp =IOMUX_TO_GPIO (MX31_PIN_GPIO1_6 ); + +mxc_iomux_set_pad (MX31_PIN_SD1_DATA0 ,MMC_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SD1_DATA1 ,MMC_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SD1_DATA2 ,MMC_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SD1_DATA3 ,MMC_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SD1_CLK ,MMC_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SD1_CMD ,MMC_PAD_CFG ); + + ret =gpio_request (gpio_det,"MMC detect" ); +if (ret) +return ret; + + ret =gpio_request (gpio_wp,"MMC w/p" ); +if (ret) + goto exit_free_det; + +gpio_direction_input (gpio_det); +gpio_direction_input (gpio_wp); + + ret =request_irq (IOMUX_TO_IRQ (MX31_PIN_DCD_DCE1 ), detect_irq, +IRQF_DISABLED |IRQF_TRIGGER_FALLING , +"MMC detect" , data); +if (ret) + goto exit_free_wp; + +return 0 ; + +exit_free_wp: +gpio_free (gpio_wp); + +exit_free_det: +gpio_free (gpio_det); + +return ret; +} + +static void mxc_mmc1_exit (struct device *dev,void *data) +{ +gpio_free (gpio_det); +gpio_free (gpio_wp); +free_irq (IOMUX_TO_IRQ (MX31_PIN_GPIO1_1 ), data); +} + +static struct imxmmc_platform_data mmc_pdata = { + .get_ro = mxc_mmc1_get_ro, + .init = mxc_mmc1_init, + .exit = mxc_mmc1_exit, +}; +void __init mx31lite_db_init (void ) {mxc_iomux_setup_multiple_pins (litekit_db_board_pins,ARRAY_SIZE (litekit_db_board_pins),"development board pins" );mxc_register_device (&mxc_uart_device0, &uart_pdata); +mxc_register_device (&mxcsdhc_device0, &mmc_pdata); }
Signature · 1 line
1.6.5.2
PATCH 3/5 ARM: MX3: add SPI devices for mx31lite
Some header files were reordered while I was at it. The only device currently registered is the ATLAS PMIC chip.
--- arch/arm/mach-mx3/mx31lite-db.c | 43 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mx3/mx31lite.c | 36 ++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +43 -0
@@ -28,6 +28,8 @@#include <linux/types.h> #include <linux/init.h> #include <linux/gpio.h> +#include <linux/spi/spi.h> +#include <linux/mfd/mc13783.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -39,6 +41,7 @@#include <mach/iomux-mx3.h> #include <mach/board-mx31lite.h> #include <mach/mmc.h> +#include <mach/spi.h> #include "devices.h"
@@ -55,6 +58,14 @@ static unsigned int litekit_db_board_pins[] __initdata = {MX31_PIN_RTS1__RTS1 ,MX31_PIN_TXD1__TXD1 ,MX31_PIN_RXD1__RXD1 , +/* SPI 0 */ +MX31_PIN_CSPI1_SCLK__SCLK , +MX31_PIN_CSPI1_MOSI__MOSI , +MX31_PIN_CSPI1_MISO__MISO , +MX31_PIN_CSPI1_SPI_RDY__SPI_RDY , +MX31_PIN_CSPI1_SS0__SS0 , +MX31_PIN_CSPI1_SS1__SS1 , + MX31_PIN_CSPI1_SS2__SS2, };/* UART */
@@ -130,6 +141,35 @@ static struct imxmmc_platform_data mmc_pdata = { .exit = mxc_mmc1_exit, }; +/* SPI */ + +static int spi_internal_chipselect[] = { +MXC_SPI_CS (0 ), +MXC_SPI_CS (1 ), +MXC_SPI_CS (2 ), +}; + +static struct spi_imx_master spi0_pdata = { + .chipselect = spi_internal_chipselect, + .num_chipselect =ARRAY_SIZE (spi_internal_chipselect), +}; + +static struct mc13783_platform_data mc13783_pdata__initdata = { + .flags =MC13783_USE_RTC | +MC13783_USE_REGULATOR , +}; + +static struct spi_board_info litekit_spi_devs[]__initdata = { + { + .modalias ="mc13783" , + .max_speed_hz =1000000 , + .bus_num =1 , + .chip_select =0 , + .platform_data = &mc13783_pdata, + .irq =IOMUX_TO_IRQ (MX31_PIN_GPIO1_3 ), + }, +}; +void __init mx31lite_db_init (void ) { mxc_iomux_setup_multiple_pins(litekit_db_board_pins,
@@ -137,5 +177,8 @@ void __init mx31lite_db_init(void) "development board pins");mxc_register_device (&mxc_uart_device0, &uart_pdata);mxc_register_device (&mxcsdhc_device0, &mmc_pdata); +mxc_register_device (&mxc_spi_device0, &spi0_pdata); +spi_register_board_info (litekit_spi_devs, +ARRAY_SIZE (litekit_spi_devs)); }
arch/arm/mach-mx3/mx31lite.c +34 -2
@@ -2,6 +2,7 @@* Copyright (C) 2000 Deep Blue Solutions Ltd * Copyright (C) 2002 Shane Nay (shane at minirl.com) * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2009 Daniel Mack <[email protected]> * * 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
@@ -26,19 +27,22 @@#include <linux/gpio.h> #include <linux/smsc911x.h> -#include <mach/hardware.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/mach/time.h> #include <asm/mach/map.h> -#include <mach/common.h> #include <asm/page.h> #include <asm/setup.h> + +#include <mach/hardware.h> +#include <mach/common.h> #include <mach/board-mx31lite.h> #include <mach/imx-uart.h> #include <mach/iomux-mx3.h> #include <mach/irqs.h> #include <mach/mxc_nand.h> +#include <mach/spi.h> +#include "devices.h" /*
@@ -48,6 +52,14 @@static unsigned int mx31lite_pins[] = {/* LAN9117 IRQ pin */ IOMUX_MODE (MX31_PIN_SFS6 ,IOMUX_CONFIG_GPIO ), +/* SPI 1 */ +MX31_PIN_CSPI2_SCLK__SCLK , +MX31_PIN_CSPI2_MOSI__MOSI , +MX31_PIN_CSPI2_MISO__MISO , +MX31_PIN_CSPI2_SPI_RDY__SPI_RDY , +MX31_PIN_CSPI2_SS0__SS0 , +MX31_PIN_CSPI2_SS1__SS1 , +MX31_PIN_CSPI2_SS2__SS2 , };static struct mxc_nand_platform_data mx31lite_nand_board_info = {
@@ -84,6 +96,25 @@ static struct platform_device smsc911x_device = { };/* +* SPI +* +* The MX13783 is hard-wired on the module, hence the corresponding +* bus is registered here and not in the board code, in contrast to +* the other SPI bus. +*/ + +static int spi_internal_chipselect[] = { +MXC_SPI_CS (0 ), +MXC_SPI_CS (1 ), +MXC_SPI_CS (2 ), +}; + +static struct spi_imx_master spi1_pdata = { + .chipselect = spi_internal_chipselect, + .num_chipselect =ARRAY_SIZE (spi_internal_chipselect), +}; + +/* * This structure defines the MX31 memory map. */ static struct map_desc mx31lite_io_desc[]__initdata = {
@@ -131,6 +162,7 @@ static void __init mxc_board_init(void) "mx31lite");mxc_register_device (&mxc_nand_device, &mx31lite_nand_board_info); +mxc_register_device (&mxc_spi_device1, &spi1_pdata);/* SMSC9117 IRQ pin */ ret =gpio_request (IOMUX_TO_GPIO (MX31_PIN_SFS6 ),"sms9117-irq" );
Signature · 1 line
1.6.5.2
PATCH 4/5 ARM: MX3: add USB functions for mx31litekit
--- arch/arm/mach-mx3/mx31lite.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite.c +60 -0
@@ -26,6 +26,8 @@#include <linux/platform_device.h> #include <linux/gpio.h> #include <linux/smsc911x.h> +#include <linux/usb/otg.h> +#include <linux/usb/ulpi.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -42,6 +44,8 @@#include <mach/irqs.h> #include <mach/mxc_nand.h> #include <mach/spi.h> +#include <mach/mxc_ehci.h> +#include <mach/ulpi.h> #include "devices.h"
@@ -115,6 +119,56 @@ static struct spi_imx_master spi1_pdata = { };/* +* USB +*/ + +#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ + PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) + +static int usbh2_init (struct platform_device *pdev) +{ +int pins[] = { +MX31_PIN_USBH2_DATA0__USBH2_DATA0 , +MX31_PIN_USBH2_DATA1__USBH2_DATA1 , +MX31_PIN_USBH2_CLK__USBH2_CLK , +MX31_PIN_USBH2_DIR__USBH2_DIR , +MX31_PIN_USBH2_NXT__USBH2_NXT , +MX31_PIN_USBH2_STP__USBH2_STP , + }; + +mxc_iomux_setup_multiple_pins (pins,ARRAY_SIZE (pins),"USB H2" ); + +mxc_iomux_set_pad (MX31_PIN_USBH2_CLK ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DIR ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_NXT ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_STP ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA0 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA1 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SRXD6 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_STXD6 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SFS3 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SCK3 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_SRXD3 ,USB_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_STXD3 ,USB_PAD_CFG ); + +mxc_iomux_set_gpr (MUX_PGP_UH2 , true); + +/* chip select */ +mxc_iomux_alloc_pin (IOMUX_MODE (MX31_PIN_DTR_DCE1 ,IOMUX_CONFIG_GPIO ), +"USBH2_CS" ); +gpio_request (IOMUX_TO_GPIO (MX31_PIN_DTR_DCE1 ),"USBH2 CS" ); +gpio_direction_output (IOMUX_TO_GPIO (MX31_PIN_DTR_DCE1 ),0 ); + +return 0 ; +} + +static struct mxc_usbh_platform_data usbh2_pdata = { + .init = usbh2_init, + .portsc =MXC_EHCI_MODE_ULPI |MXC_EHCI_UTMI_8BIT , + .flags =MXC_EHCI_POWER_PINS_ENABLED , +}; + +/* * This structure defines the MX31 memory map. */ static struct map_desc mx31lite_io_desc[]__initdata = {
@@ -164,6 +218,12 @@ static void __init mxc_board_init(void)mxc_register_device (&mxc_nand_device, &mx31lite_nand_board_info);mxc_register_device (&mxc_spi_device1, &spi1_pdata); +/* USB */ + usbh2_pdata.otg =otg_ulpi_create (&mxc_ulpi_access_ops, +USB_OTG_DRV_VBUS |USB_OTG_DRV_VBUS_EXT ); + +mxc_register_device (&mxc_usbh2, &usbh2_pdata); +/* SMSC9117 IRQ pin */ ret =gpio_request (IOMUX_TO_GPIO (MX31_PIN_SFS6 ),"sms9117-irq" );if (ret)
Signature · 1 line
1.6.5.2
PATCH 5/5 ARM: MX3: add support for GPIO LEDs on litekit db
The names are chosen to match the silkscreen.
--- arch/arm/mach-mx3/mx31lite-db.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +33 -0
@@ -30,6 +30,8 @@#include <linux/gpio.h> #include <linux/spi/spi.h> #include <linux/mfd/mc13783.h> +#include <linux/leds.h> +#include <linux/platform_device.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -170,6 +172,36 @@ static struct spi_board_info litekit_spi_devs[] __initdata = { }, }; +/* GPIO LEDs */ + +static struct gpio_led litekit_leds[] = { + { + .name ="GPIO0" , + .gpio =IOMUX_TO_GPIO (MX31_PIN_COMPARE ), + .active_low =1 , + .default_state =LEDS_GPIO_DEFSTATE_OFF , + }, + { + .name ="GPIO1" , + .gpio =IOMUX_TO_GPIO (MX31_PIN_CAPTURE ), + .active_low =1 , + .default_state =LEDS_GPIO_DEFSTATE_OFF , + } +}; + +static struct gpio_led_platform_data litekit_led_platform_data = { + .leds = litekit_leds, + .num_leds =ARRAY_SIZE (litekit_leds), +}; + +static struct platform_device litekit_led_device = { + .name ="leds-gpio" , + .id =-1 , + .dev = { + .platform_data = &litekit_led_platform_data, + }, +}; +void __init mx31lite_db_init (void ) { mxc_iomux_setup_multiple_pins(litekit_db_board_pins,
@@ -180,5 +212,6 @@ void __init mx31lite_db_init(void)mxc_register_device (&mxc_spi_device0, &spi0_pdata);spi_register_board_info (litekit_spi_devs,ARRAY_SIZE (litekit_spi_devs)); +platform_device_register (&litekit_led_device); }
Signature · 1 line
1.6.5.2
Sascha Hauer
maintainerPATCH 3/5 ARM: MX3: add SPI devices for mx31lite
In reply to Daniel MackHi Daniel,
Quoted 143 lines · Daniel Mack
Some header files were reordered while I was at it. The only device currently registered is the ATLAS PMIC chip.
Signed-off-by Daniel Mack <[email protected]>--- arch/arm/mach-mx3/mx31lite-db.c | 43 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mx3/mx31lite.c | 36 ++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-)arch/arm/mach-mx3/mx31lite-db.c +43
-0@@ -28,6 +28,8 @@#include <linux/types.h> #include <linux/init.h> #include <linux/gpio.h> +#include <linux/spi/spi.h> +#include <linux/mfd/mc13783.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> @@ -39,6 +41,7 @@#include <mach/iomux-mx3.h> #include <mach/board-mx31lite.h> #include <mach/mmc.h> +#include <mach/spi.h> #include "devices.h" @@ -55,6 +58,14 @@ static unsigned int litekit_db_board_pins[] __initdata = {MX31_PIN_RTS1__RTS1 ,MX31_PIN_TXD1__TXD1 ,MX31_PIN_RXD1__RXD1 , +/* SPI 0 */ +MX31_PIN_CSPI1_SCLK__SCLK , +MX31_PIN_CSPI1_MOSI__MOSI , +MX31_PIN_CSPI1_MISO__MISO , +MX31_PIN_CSPI1_SPI_RDY__SPI_RDY , +MX31_PIN_CSPI1_SS0__SS0 , +MX31_PIN_CSPI1_SS1__SS1 , + MX31_PIN_CSPI1_SS2__SS2, };/* UART */ @@ -130,6 +141,35 @@ static struct imxmmc_platform_data mmc_pdata = { .exit = mxc_mmc1_exit, }; +/* SPI */ + +static int spi_internal_chipselect[] = { +MXC_SPI_CS (0 ), +MXC_SPI_CS (1 ), +MXC_SPI_CS (2 ), +}; + +static struct spi_imx_master spi0_pdata = { + .chipselect = spi_internal_chipselect, + .num_chipselect =ARRAY_SIZE (spi_internal_chipselect), +}; + +static struct mc13783_platform_data mc13783_pdata__initdata = { + .flags =MC13783_USE_RTC | +MC13783_USE_REGULATOR , +}; + +static struct spi_board_info litekit_spi_devs[]__initdata = { + { + .modalias ="mc13783" , + .max_speed_hz =1000000 , + .bus_num =1 , + .chip_select =0 , + .platform_data = &mc13783_pdata, + .irq =IOMUX_TO_IRQ (MX31_PIN_GPIO1_3 ), + }, +}; +void __init mx31lite_db_init (void ) { mxc_iomux_setup_multiple_pins(litekit_db_board_pins,@@ -137,5 +177,8 @@ void __init mx31lite_db_init(void) "development board pins");mxc_register_device (&mxc_uart_device0, &uart_pdata);mxc_register_device (&mxcsdhc_device0, &mmc_pdata); +mxc_register_device (&mxc_spi_device0, &spi0_pdata); +spi_register_board_info (litekit_spi_devs, +ARRAY_SIZE (litekit_spi_devs)); }arch/arm/mach-mx3/mx31lite.c +14
-2@@ -2,6 +2,7 @@* Copyright (C) 2000 Deep Blue Solutions Ltd * Copyright (C) 2002 Shane Nay (shane at minirl.com) * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2009 Daniel Mack <[email protected]> * * 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 @@ -26,19 +27,22 @@#include <linux/gpio.h> #include <linux/smsc911x.h> -#include <mach/hardware.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/mach/time.h> #include <asm/mach/map.h> -#include <mach/common.h> #include <asm/page.h> #include <asm/setup.h> + +#include <mach/hardware.h> +#include <mach/common.h> #include <mach/board-mx31lite.h> #include <mach/imx-uart.h> #include <mach/iomux-mx3.h> #include <mach/irqs.h> #include <mach/mxc_nand.h> +#include <mach/spi.h> +#include "devices.h" /* @@ -48,6 +52,14 @@static unsigned int mx31lite_pins[] = {/* LAN9117 IRQ pin */ IOMUX_MODE (MX31_PIN_SFS6 ,IOMUX_CONFIG_GPIO ), +/* SPI 1 */ +MX31_PIN_CSPI2_SCLK__SCLK , +MX31_PIN_CSPI2_MOSI__MOSI , +MX31_PIN_CSPI2_MISO__MISO , +MX31_PIN_CSPI2_SPI_RDY__SPI_RDY , +MX31_PIN_CSPI2_SS0__SS0 , +MX31_PIN_CSPI2_SS1__SS1 , +MX31_PIN_CSPI2_SS2__SS2 , };static struct mxc_nand_platform_data mx31lite_nand_board_info = {
arch/arm/mach-mx3/mx31lite.c static struct platform_device smsc911x_device = { · line 104
Quoted 9 lines
arch/arm/mach-mx3/mx31lite.c +6
-0@@ -84,6 +96,25 @@ static struct platform_device smsc911x_device = { };/* +* SPI +* +* The MX13783 is hard-wired on the module, hence the corresponding +* bus is registered here and not in the board code, in contrast to +* the other SPI bus. +*/
The mc13783 bus is registered in the -db file, and not here. I think you mixed something up here.
s/MX13783/MC13783/
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 3/5 ARM: MX3: add SPI devices for mx31lite
Quoted 10 lines · Sascha Hauer
Quoted 7 lines · Daniel Mack
/*
+ * SPI
+ *
+ * The MX13783 is hard-wired on the module, hence the corresponding
+ * bus is registered here and not in the board code, in contrast to
+ * the other SPI bus.
+ */
Quoted 2 lines
The mc13783 bus is registered in the -db file, and not here. I think you mixed something up here.
Hmm, no, that actually correct. The problem is that all devices on the SPI bus have to be registered in one block via spi_register_board_info, and as I don't know whether other boards will have more devices connected, the registration is done in the board support file, not in the module code.
The bus itself, however, is hardwired, so it makes no sense to add it conditionally.
Quoted 1 line
s/MX13783/MC13783/
That's true :) Care to fix it on the fly or do you want me to resend? There is btw another typo in the first mail of this series: In its subject, it should have 'ARM' not 'ARN'.
The tradeoff of too small terminal fonts ;)
Daniel
Sascha Hauer
maintainerPATCH 3/5 ARM: MX3: add SPI devices for mx31lite
Quoted 11 lines · Daniel Mack
Quoted 10 lines · Sascha Hauer
Quoted 7 lines · Daniel Mack
/*
+ * SPI
+ *
+ * The MX13783 is hard-wired on the module, hence the corresponding
+ * bus is registered here and not in the board code, in contrast to
+ * the other SPI bus.
+ */
Quoted 5 lines
Quoted 2 lines
The mc13783 bus is registered in the -db file, and not here. I think you mixed something up here.
Hmm, no, that actually correct. The problem is that all devices on the SPI bus have to be registered in one block via
spi_register_board_info,
Looking at the SPI code I see no reason why it shouldn't be possible to call spi_register_board_info multiple times.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 3/5 ARM: MX3: add SPI devices for mx31lite
Quoted 12 lines · Sascha Hauer
Quoted 11 lines · Daniel Mack
Quoted 10 lines · Sascha Hauer
Quoted 7 lines · Daniel Mack
/*
+ * SPI
+ *
+ * The MX13783 is hard-wired on the module, hence the corresponding
+ * bus is registered here and not in the board code, in contrast to
+ * the other SPI bus.
+ */
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The mc13783 bus is registered in the -db file, and not here. I think you mixed something up here.
Hmm, no, that actually correct. The problem is that all devices on the SPI bus have to be registered in one block via
spi_register_board_info,Looking at the SPI code I see no reason why it shouldn't be possible to call
spi_register_board_infomultiple times.
Hmm ok, I didn't know that. I changed that and rebased the patches on top of this. I'll resend the whole series later.
Thanks,
Daniel