190b8fc34SJaya Kumar /* 290b8fc34SJaya Kumar * linux/arch/arm/mach-pxa/gumstix.c 390b8fc34SJaya Kumar * 490b8fc34SJaya Kumar * Support for the Gumstix motherboards. 590b8fc34SJaya Kumar * 690b8fc34SJaya Kumar * Original Author: Craig Hughes 790b8fc34SJaya Kumar * Created: Feb 14, 2008 890b8fc34SJaya Kumar * Copyright: Craig Hughes 990b8fc34SJaya Kumar * 1090b8fc34SJaya Kumar * This program is free software; you can redistribute it and/or modify 1190b8fc34SJaya Kumar * it under the terms of the GNU General Public License version 2 as 1290b8fc34SJaya Kumar * published by the Free Software Foundation. 1390b8fc34SJaya Kumar * 1490b8fc34SJaya Kumar * Implemented based on lubbock.c by Nicolas Pitre and code from Craig 1590b8fc34SJaya Kumar * Hughes 1690b8fc34SJaya Kumar */ 1790b8fc34SJaya Kumar 1890b8fc34SJaya Kumar #include <linux/module.h> 1990b8fc34SJaya Kumar #include <linux/kernel.h> 2090b8fc34SJaya Kumar #include <linux/init.h> 2190b8fc34SJaya Kumar #include <linux/platform_device.h> 2290b8fc34SJaya Kumar #include <linux/interrupt.h> 23*d8ad7859SJaya Kumar #include <linux/delay.h> 2490b8fc34SJaya Kumar #include <linux/mtd/mtd.h> 2590b8fc34SJaya Kumar #include <linux/mtd/partitions.h> 26*d8ad7859SJaya Kumar #include <linux/gpio.h> 27*d8ad7859SJaya Kumar #include <linux/err.h> 28*d8ad7859SJaya Kumar #include <linux/clk.h> 2990b8fc34SJaya Kumar 3090b8fc34SJaya Kumar #include <asm/setup.h> 3190b8fc34SJaya Kumar #include <asm/memory.h> 3290b8fc34SJaya Kumar #include <asm/mach-types.h> 33a09e64fbSRussell King #include <mach/hardware.h> 3490b8fc34SJaya Kumar #include <asm/irq.h> 3590b8fc34SJaya Kumar #include <asm/sizes.h> 3690b8fc34SJaya Kumar 3790b8fc34SJaya Kumar #include <asm/mach/arch.h> 3890b8fc34SJaya Kumar #include <asm/mach/map.h> 3990b8fc34SJaya Kumar #include <asm/mach/irq.h> 4090b8fc34SJaya Kumar #include <asm/mach/flash.h> 41a09e64fbSRussell King #include <mach/mmc.h> 42a09e64fbSRussell King #include <mach/udc.h> 43a09e64fbSRussell King #include <mach/gumstix.h> 4490b8fc34SJaya Kumar 45a09e64fbSRussell King #include <mach/pxa-regs.h> 46a09e64fbSRussell King #include <mach/pxa2xx-regs.h> 47*d8ad7859SJaya Kumar #include <mach/mfp-pxa25x.h> 4890b8fc34SJaya Kumar 4990b8fc34SJaya Kumar #include "generic.h" 5090b8fc34SJaya Kumar 5190b8fc34SJaya Kumar static struct resource flash_resource = { 5290b8fc34SJaya Kumar .start = 0x00000000, 5390b8fc34SJaya Kumar .end = SZ_64M - 1, 5490b8fc34SJaya Kumar .flags = IORESOURCE_MEM, 5590b8fc34SJaya Kumar }; 5690b8fc34SJaya Kumar 5790b8fc34SJaya Kumar static struct mtd_partition gumstix_partitions[] = { 5890b8fc34SJaya Kumar { 5990b8fc34SJaya Kumar .name = "Bootloader", 6090b8fc34SJaya Kumar .size = 0x00040000, 6190b8fc34SJaya Kumar .offset = 0, 6290b8fc34SJaya Kumar .mask_flags = MTD_WRITEABLE /* force read-only */ 6390b8fc34SJaya Kumar } , { 6490b8fc34SJaya Kumar .name = "rootfs", 6590b8fc34SJaya Kumar .size = MTDPART_SIZ_FULL, 6690b8fc34SJaya Kumar .offset = MTDPART_OFS_APPEND 6790b8fc34SJaya Kumar } 6890b8fc34SJaya Kumar }; 6990b8fc34SJaya Kumar 7090b8fc34SJaya Kumar static struct flash_platform_data gumstix_flash_data = { 7190b8fc34SJaya Kumar .map_name = "cfi_probe", 7290b8fc34SJaya Kumar .parts = gumstix_partitions, 7390b8fc34SJaya Kumar .nr_parts = ARRAY_SIZE(gumstix_partitions), 7490b8fc34SJaya Kumar .width = 2, 7590b8fc34SJaya Kumar }; 7690b8fc34SJaya Kumar 7790b8fc34SJaya Kumar static struct platform_device gumstix_flash_device = { 7890b8fc34SJaya Kumar .name = "pxa2xx-flash", 7990b8fc34SJaya Kumar .id = 0, 8090b8fc34SJaya Kumar .dev = { 8190b8fc34SJaya Kumar .platform_data = &gumstix_flash_data, 8290b8fc34SJaya Kumar }, 8390b8fc34SJaya Kumar .resource = &flash_resource, 8490b8fc34SJaya Kumar .num_resources = 1, 8590b8fc34SJaya Kumar }; 8690b8fc34SJaya Kumar 8790b8fc34SJaya Kumar static struct platform_device *devices[] __initdata = { 8890b8fc34SJaya Kumar &gumstix_flash_device, 8990b8fc34SJaya Kumar }; 9090b8fc34SJaya Kumar 9190b8fc34SJaya Kumar #ifdef CONFIG_MMC_PXA 9290b8fc34SJaya Kumar static struct pxamci_platform_data gumstix_mci_platform_data = { 9390b8fc34SJaya Kumar .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 9490b8fc34SJaya Kumar }; 9590b8fc34SJaya Kumar 9690b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 9790b8fc34SJaya Kumar { 9890b8fc34SJaya Kumar pxa_set_mci_info(&gumstix_mci_platform_data); 9990b8fc34SJaya Kumar } 10090b8fc34SJaya Kumar #else 10190b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 10290b8fc34SJaya Kumar { 103*d8ad7859SJaya Kumar pr_debug("Gumstix mmc disabled\n"); 10490b8fc34SJaya Kumar } 10590b8fc34SJaya Kumar #endif 10690b8fc34SJaya Kumar 107*d8ad7859SJaya Kumar #ifdef CONFIG_USB_GADGET_PXA25X 10890b8fc34SJaya Kumar static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = { 10990b8fc34SJaya Kumar .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, 11090b8fc34SJaya Kumar .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx, 11190b8fc34SJaya Kumar }; 11290b8fc34SJaya Kumar 11390b8fc34SJaya Kumar static void __init gumstix_udc_init(void) 11490b8fc34SJaya Kumar { 11590b8fc34SJaya Kumar pxa_set_udc_info(&gumstix_udc_info); 11690b8fc34SJaya Kumar } 11790b8fc34SJaya Kumar #else 11890b8fc34SJaya Kumar static void gumstix_udc_init(void) 11990b8fc34SJaya Kumar { 120*d8ad7859SJaya Kumar pr_debug("Gumstix udc is disabled\n"); 12190b8fc34SJaya Kumar } 12290b8fc34SJaya Kumar #endif 12390b8fc34SJaya Kumar 124*d8ad7859SJaya Kumar #ifdef CONFIG_BT 125*d8ad7859SJaya Kumar /* Normally, the bootloader would have enabled this 32kHz clock but many 126*d8ad7859SJaya Kumar ** boards still have u-boot 1.1.4 so we check if it has been turned on and 127*d8ad7859SJaya Kumar ** if not, we turn it on with a warning message. */ 128*d8ad7859SJaya Kumar static void gumstix_setup_bt_clock(void) 129*d8ad7859SJaya Kumar { 130*d8ad7859SJaya Kumar int timeout = 500; 131*d8ad7859SJaya Kumar 132*d8ad7859SJaya Kumar if (!(OSCC & OSCC_OOK)) 133*d8ad7859SJaya Kumar pr_warning("32kHz clock was not on. Bootloader may need to " 134*d8ad7859SJaya Kumar "be updated\n"); 135*d8ad7859SJaya Kumar else 136*d8ad7859SJaya Kumar return; 137*d8ad7859SJaya Kumar 138*d8ad7859SJaya Kumar OSCC |= OSCC_OON; 139*d8ad7859SJaya Kumar do { 140*d8ad7859SJaya Kumar if (OSCC & OSCC_OOK) 141*d8ad7859SJaya Kumar break; 142*d8ad7859SJaya Kumar udelay(1); 143*d8ad7859SJaya Kumar } while (--timeout); 144*d8ad7859SJaya Kumar if (!timeout) 145*d8ad7859SJaya Kumar pr_err("Failed to start 32kHz clock\n"); 146*d8ad7859SJaya Kumar } 147*d8ad7859SJaya Kumar 148*d8ad7859SJaya Kumar static void __init gumstix_bluetooth_init(void) 149*d8ad7859SJaya Kumar { 150*d8ad7859SJaya Kumar int err; 151*d8ad7859SJaya Kumar 152*d8ad7859SJaya Kumar gumstix_setup_bt_clock(); 153*d8ad7859SJaya Kumar 154*d8ad7859SJaya Kumar err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); 155*d8ad7859SJaya Kumar if (err) { 156*d8ad7859SJaya Kumar pr_err("gumstix: failed request gpio for bluetooth reset\n"); 157*d8ad7859SJaya Kumar return; 158*d8ad7859SJaya Kumar } 159*d8ad7859SJaya Kumar 160*d8ad7859SJaya Kumar err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); 161*d8ad7859SJaya Kumar if (err) { 162*d8ad7859SJaya Kumar pr_err("gumstix: can't reset bluetooth\n"); 163*d8ad7859SJaya Kumar return; 164*d8ad7859SJaya Kumar } 165*d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); 166*d8ad7859SJaya Kumar udelay(100); 167*d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); 168*d8ad7859SJaya Kumar } 169*d8ad7859SJaya Kumar #else 170*d8ad7859SJaya Kumar static void gumstix_bluetooth_init(void) 171*d8ad7859SJaya Kumar { 172*d8ad7859SJaya Kumar pr_debug("Gumstix Bluetooth is disabled\n"); 173*d8ad7859SJaya Kumar } 174*d8ad7859SJaya Kumar #endif 175*d8ad7859SJaya Kumar 176*d8ad7859SJaya Kumar static unsigned long gumstix_pin_config[] __initdata = { 177*d8ad7859SJaya Kumar GPIO12_32KHz, 178*d8ad7859SJaya Kumar /* BTUART */ 179*d8ad7859SJaya Kumar GPIO42_HWUART_RXD, 180*d8ad7859SJaya Kumar GPIO43_HWUART_TXD, 181*d8ad7859SJaya Kumar GPIO44_HWUART_CTS, 182*d8ad7859SJaya Kumar GPIO45_HWUART_RTS, 183*d8ad7859SJaya Kumar /* MMC */ 184*d8ad7859SJaya Kumar GPIO6_MMC_CLK, 185*d8ad7859SJaya Kumar GPIO53_MMC_CLK, 186*d8ad7859SJaya Kumar GPIO8_MMC_CS0, 187*d8ad7859SJaya Kumar /* these are used by AM200EPD */ 188*d8ad7859SJaya Kumar GPIO51_GPIO, 189*d8ad7859SJaya Kumar GPIO49_GPIO, 190*d8ad7859SJaya Kumar GPIO48_GPIO, 191*d8ad7859SJaya Kumar GPIO32_GPIO, 192*d8ad7859SJaya Kumar GPIO17_GPIO, 193*d8ad7859SJaya Kumar GPIO16_GPIO, 194*d8ad7859SJaya Kumar }; 195*d8ad7859SJaya Kumar 19690b8fc34SJaya Kumar static void __init gumstix_init(void) 19790b8fc34SJaya Kumar { 198*d8ad7859SJaya Kumar pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config)); 199*d8ad7859SJaya Kumar 200*d8ad7859SJaya Kumar gumstix_bluetooth_init(); 20190b8fc34SJaya Kumar gumstix_udc_init(); 20290b8fc34SJaya Kumar gumstix_mmc_init(); 20390b8fc34SJaya Kumar (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 20490b8fc34SJaya Kumar } 20590b8fc34SJaya Kumar 20690b8fc34SJaya Kumar MACHINE_START(GUMSTIX, "Gumstix") 20790b8fc34SJaya Kumar .phys_io = 0x40000000, 20890b8fc34SJaya Kumar .boot_params = 0xa0000100, /* match u-boot bi_boot_params */ 20990b8fc34SJaya Kumar .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 21090b8fc34SJaya Kumar .map_io = pxa_map_io, 21190b8fc34SJaya Kumar .init_irq = pxa25x_init_irq, 21290b8fc34SJaya Kumar .timer = &pxa_timer, 21390b8fc34SJaya Kumar .init_machine = gumstix_init, 21490b8fc34SJaya Kumar MACHINE_END 215