Created wrapper to add omap devices. Signed-off-by: Teresa Gámez <t.ga...@phytec.de> --- arch/arm/mach-omap/Makefile | 4 +- arch/arm/mach-omap/devices.c | 69 +++++++++++++++++++ arch/arm/mach-omap/include/mach/am33xx-devices.h | 36 ++++++++++ arch/arm/mach-omap/include/mach/devices.h | 27 ++++++++ arch/arm/mach-omap/include/mach/omap3-devices.h | 60 ++++++++++++++++- arch/arm/mach-omap/include/mach/omap4-devices.h | 77 ++++++++++++++++++++++ 6 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-omap/devices.c create mode 100644 arch/arm/mach-omap/include/mach/am33xx-devices.h create mode 100644 arch/arm/mach-omap/include/mach/devices.h create mode 100644 arch/arm/mach-omap/include/mach/omap4-devices.h
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index 1536744..494da4e 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -15,8 +15,8 @@ # GNU General Public License for more details. # # -obj-$(CONFIG_ARCH_OMAP) += syslib.o -pbl-$(CONFIG_ARCH_OMAP) += syslib.o +obj-$(CONFIG_ARCH_OMAP) += syslib.o devices.o +pbl-$(CONFIG_ARCH_OMAP) += syslib.o devices.o obj-$(CONFIG_OMAP_CLOCK_SOURCE_S32K) += s32k_clksource.o obj-$(CONFIG_OMAP_CLOCK_SOURCE_DMTIMER0) += dmtimer0.o obj-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o diff --git a/arch/arm/mach-omap/devices.c b/arch/arm/mach-omap/devices.c new file mode 100644 index 0000000..011db5a --- /dev/null +++ b/arch/arm/mach-omap/devices.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Teresa Gámez, Phytec Messtechnik GmbH + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <driver.h> +#include <sizes.h> +#include <ns16550.h> +#include <asm/armlinux.h> +#include <mach/devices.h> + +static inline struct device_d *omap_add_device(char *name, resource_size_t base, + resource_size_t size, void *pdata) +{ + return add_generic_device(name, DEVICE_ID_DYNAMIC, NULL, + base, size, IORESOURCE_MEM, pdata); +} + +void omap_add_ram0(resource_size_t size) +{ + arm_add_mem_device("ram0", 0x80000000, size); +} + +void omap_add_sram0(resource_size_t base, resource_size_t size) +{ + add_mem_device("sram0", base, size, IORESOURCE_MEM_WRITEABLE); +} + +static struct NS16550_plat serial_plat = { + .clock = 48000000, /* 48MHz (APLL96/2) */ + .shift = 2, +}; + +struct device_d *omap_add_ns16550(resource_size_t base) +{ + return add_ns16550_device(DEVICE_ID_DYNAMIC, base, SZ_1K, + IORESOURCE_MEM_8BIT, &serial_plat); +} + +struct device_d *omap_add_mmc(resource_size_t base, void *pdata) +{ + return omap_add_device("omap-hsmmc", base, SZ_4K, pdata); +} + +struct device_d *omap_add_i2c(resource_size_t base, void *pdata) +{ + return omap_add_device("i2c-omap", base, SZ_4K, pdata); +} + +struct device_d *omap_add_spi(int id, resource_size_t base, void *pdata) +{ + return add_generic_device("omap3_spi", id, NULL, + base, SZ_4K, IORESOURCE_MEM, pdata); +} diff --git a/arch/arm/mach-omap/include/mach/am33xx-devices.h b/arch/arm/mach-omap/include/mach/am33xx-devices.h new file mode 100644 index 0000000..40ce854 --- /dev/null +++ b/arch/arm/mach-omap/include/mach/am33xx-devices.h @@ -0,0 +1,36 @@ +#include <driver.h> +#include <sizes.h> + +#include <mach/devices.h> +#include <mach/mcspi.h> +#include <mach/am33xx-silicon.h> + +static inline struct device_d *am33xx_add_ns16550_uart0(void) +{ + return omap_add_ns16550(AM33XX_UART0_BASE); +} + +static inline struct device_d *am33xx_add_ns16550_uart1(void) +{ + return omap_add_ns16550(AM33XX_UART1_BASE); +} + +static inline struct device_d *am33xx_add_ns16550_uart2(void) +{ + return omap_add_ns16550(AM33XX_UART2_BASE); +} + +static inline struct device_d *am33xx_add_mmc0(void *pdata) +{ + return omap_add_mmc(AM33XX_MMCHS0_BASE + 0x100, pdata); +} + +static inline struct device_d *am33xx_add_mmc1(void *pdata) +{ + return omap_add_mmc(AM33XX_MMC1_BASE + 0x100, pdata); +} + +static inline struct device_d *am33xx_add_mmc2(void *pdata) +{ + return omap_add_mmc(AM33XX_MMCHS2_BASE + 0x100, pdata); +} diff --git a/arch/arm/mach-omap/include/mach/devices.h b/arch/arm/mach-omap/include/mach/devices.h new file mode 100644 index 0000000..3841558 --- /dev/null +++ b/arch/arm/mach-omap/include/mach/devices.h @@ -0,0 +1,27 @@ +/* + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + */ + +#ifndef __ASM_ARCH_OMAP_DEVICES_H +#define __ASM_ARCH_OMAP_DEVICES_H + +void omap_add_ram0(resource_size_t size); +void omap_add_sram0(resource_size_t base, resource_size_t size); +struct device_d *omap_add_ns16550(resource_size_t base); +struct device_d *omap_add_mmc(resource_size_t base, void *pdata); +struct device_d *omap_add_i2c(resource_size_t base, void *pdata); +struct device_d *omap_add_spi(int id, resource_size_t base, void *pdata); + +#endif diff --git a/arch/arm/mach-omap/include/mach/omap3-devices.h b/arch/arm/mach-omap/include/mach/omap3-devices.h index 8a6b324..35ee51c 100644 --- a/arch/arm/mach-omap/include/mach/omap3-devices.h +++ b/arch/arm/mach-omap/include/mach/omap3-devices.h @@ -1,14 +1,70 @@ #include <driver.h> #include <sizes.h> +#include <mach/devices.h> #include <mach/mcspi.h> +#include <mach/omap3-silicon.h> + +static inline void omap3_add_sram0(void) +{ + return omap_add_sram0(OMAP_SRAM_BASE, 64 * SZ_1K); +} + +static inline struct device_d *omap3_add_ns16550_uart1(void) +{ + return omap_add_ns16550(OMAP_UART1_BASE); +} + +static inline struct device_d *omap3_add_ns16550_uart2(void) +{ + return omap_add_ns16550(OMAP_UART2_BASE); +} + +static inline struct device_d *omap3_add_ns16550_uart3(void) +{ + return omap_add_ns16550(OMAP_UART3_BASE); +} +static inline struct device_d *omap3_add_i2c1(void *pdata) +{ + return omap_add_i2c(OMAP_I2C1_BASE, pdata); +} + +static inline struct device_d *omap3_add_i2c2(void *pdata) +{ + return omap_add_i2c(OMAP_I2C2_BASE, pdata); +} + +static inline struct device_d *omap3_add_i2c3(void *pdata) +{ + return omap_add_i2c(OMAP_I2C3_BASE, pdata); +} + +static inline struct device_d *omap3_add_mmc1(void *pdata) +{ + return omap_add_mmc(OMAP_MMC1_BASE, pdata); +} + +static inline struct device_d *omap3_add_mmc2(void *pdata) +{ + return omap_add_mmc(OMAP_MMC2_BASE, pdata); +} + +static inline struct device_d *omap3_add_mmc3(void *pdata) +{ + return omap_add_mmc(OMAP_MMC3_BASE, pdata); +} + +static inline struct device_d *omap3_add_ehci(void *pdata) +{ + return add_usb_ehci_device(DEVICE_ID_DYNAMIC, OMAP_EHCI_BASE, + OMAP_EHCI_BASE + 0x10, pdata); +} /* the device numbering is the same as in the device tree */ static inline struct device_d *omap3_add_spi(int id, resource_size_t start) { - return add_generic_device("omap3_spi", id, NULL, start, SZ_4K, - IORESOURCE_MEM, NULL); + return omap_add_spi(id, start, NULL); } static inline struct device_d *omap3_add_spi1(void) diff --git a/arch/arm/mach-omap/include/mach/omap4-devices.h b/arch/arm/mach-omap/include/mach/omap4-devices.h new file mode 100644 index 0000000..0f58cc9 --- /dev/null +++ b/arch/arm/mach-omap/include/mach/omap4-devices.h @@ -0,0 +1,77 @@ +#include <driver.h> +#include <sizes.h> + +#include <mach/devices.h> +#include <mach/omap4-silicon.h> + +static inline void omap4_add_sram0(void) +{ + return omap_add_sram0(OMAP44XX_SRAM_BASE, 48 * SZ_1K); +} + +static inline struct device_d *omap4_add_ns16550_uart1(void) +{ + return omap_add_ns16550(OMAP44XX_UART1_BASE); +} + +static inline struct device_d *omap4_add_ns16550_uart2(void) +{ + return omap_add_ns16550(OMAP44XX_UART2_BASE); +} + +static inline struct device_d *omap4_add_ns16550_uart3(void) +{ + return omap_add_ns16550(OMAP44XX_UART3_BASE); +} + +static inline struct device_d *omap4_add_i2c1(void *pdata) +{ + return omap_add_i2c(OMAP44XX_I2C1_BASE, pdata); +} + +static inline struct device_d *omap4_add_i2c2(void *pdata) +{ + return omap_add_i2c(OMAP44XX_I2C2_BASE, pdata); +} + +static inline struct device_d *omap4_add_i2c3(void *pdata) +{ + return omap_add_i2c(OMAP44XX_I2C3_BASE, pdata); +} + +static inline struct device_d *omap4_add_i2c4(void *pdata) +{ + return omap_add_i2c(OMAP44XX_I2C4_BASE, pdata); +} + +static inline struct device_d *omap4_add_mmc1(void *pdata) +{ + return omap_add_mmc(OMAP44XX_MMC1_BASE, pdata); +} + +static inline struct device_d *omap4_add_mmc2(void *pdata) +{ + return omap_add_mmc(OMAP44XX_MMC2_BASE, pdata); +} + +static inline struct device_d *omap4_add_mmc3(void *pdata) +{ + return omap_add_mmc(OMAP44XX_MMC3_BASE, pdata); +} + +static inline struct device_d *omap4_add_mmc4(void *pdata) +{ + return omap_add_mmc(OMAP44XX_MMC4_BASE, pdata); +} + +static inline struct device_d *omap4_add_mmc5(void *pdata) +{ + return omap_add_mmc(OMAP44XX_MMC5_BASE, pdata); +} + +static inline struct device_d *omap4_add_ehci(void *pdata) +{ + return add_usb_ehci_device(DEVICE_ID_DYNAMIC, OMAP44XX_EHCI_BASE, + OMAP44XX_EHCI_BASE + 0x10, pdata); +} + -- 1.7.0.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox