ARM: MX3: modularize 'mx31lite' code
Subsystems (3)
PATCH 1/6 ARM: 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
@@ -9,7 +9,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/6 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/6 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 (MC13783) chip.
--- arch/arm/mach-mx3/mx31lite-db.c | 24 +++++++++++++++++++ arch/arm/mach-mx3/mx31lite.c | 49 +++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/mx31lite-db.c +24 -0
@@ -28,6 +28,7 @@#include <linux/types.h> #include <linux/init.h> #include <linux/gpio.h> +#include <linux/platform_device.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -39,6 +40,7 @@#include <mach/iomux-mx3.h> #include <mach/board-mx31lite.h> #include <mach/mmc.h> +#include <mach/spi.h> #include "devices.h"
@@ -55,6 +57,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 +140,19 @@ 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), +}; +void __init mx31lite_db_init (void ) { mxc_iomux_setup_multiple_pins(litekit_db_board_pins,
@@ -137,5 +160,6 @@ 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); }
arch/arm/mach-mx3/mx31lite.c +47 -2
91 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 4/6 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
@@ -28,6 +28,8 @@#include <linux/smsc911x.h> #include <linux/mfd/mc13783.h> #include <linux/spi/spi.h> +#include <linux/usb/otg.h> +#include <linux/usb/ulpi.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -44,6 +46,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"
@@ -127,6 +131,56 @@ static struct spi_board_info mc13783_spi_dev __initdata = { };/* +* 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 = {
@@ -177,6 +231,12 @@ static void __init mxc_board_init(void)mxc_register_device (&mxc_spi_device1, &spi1_pdata);spi_register_board_info (&mc13783_spi_dev,1 ); +/* 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/6 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
@@ -29,6 +29,8 @@#include <linux/init.h> #include <linux/gpio.h> #include <linux/platform_device.h> +#include <linux/leds.h> +#include <linux/platform_device.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -153,6 +155,36 @@ static struct spi_imx_master spi0_pdata = { .num_chipselect = ARRAY_SIZE(spi_internal_chipselect), }; +/* 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,
@@ -161,5 +193,6 @@ void __init mx31lite_db_init(void)mxc_register_device (&mxc_uart_device0, &uart_pdata);mxc_register_device (&mxcsdhc_device0, &mmc_pdata);mxc_register_device (&mxc_spi_device0, &spi0_pdata); +platform_device_register (&litekit_led_device); }
Signature · 1 line
1.6.5.2
PATCH 6/6 ARM: MX3: add NOR flash support via physmap mtd driver
--- arch/arm/mach-mx3/mx31lite.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/mx31lite.c +30 -0
@@ -30,6 +30,7 @@#include <linux/spi/spi.h> #include <linux/usb/otg.h> #include <linux/usb/ulpi.h> +#include <linux/mtd/physmap.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -181,6 +182,32 @@ static struct mxc_usbh_platform_data usbh2_pdata = { };/* +* NOR flash +*/ + +static struct physmap_flash_data nor_flash_data = { + .width =2 , +}; + +static struct resource nor_flash_resource = { + .start =0xa0000000 , + .end =0xa1ffffff , + .flags =IORESOURCE_MEM , +}; + +static struct platform_device physmap_flash_device = { + .name ="physmap-flash" , + .id =0 , + .dev = { + .platform_data = &nor_flash_data, + }, + .resource = &nor_flash_resource, + .num_resources =1 , +}; + + + +/* * This structure defines the MX31 memory map. */ static struct map_desc mx31lite_io_desc[]__initdata = {
@@ -227,7 +254,10 @@ static void __init mxc_board_init(void)mxc_iomux_setup_multiple_pins (mx31lite_pins,ARRAY_SIZE (mx31lite_pins),"mx31lite" ); +/* NOR and NAND flash */ +platform_device_register (&physmap_flash_device);mxc_register_device (&mxc_nand_device, &mx31lite_nand_board_info); +mxc_register_device (&mxc_spi_device1, &spi1_pdata);spi_register_board_info (&mc13783_spi_dev,1 );
Signature · 1 line
1.6.5.2