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> 23d8ad7859SJaya Kumar #include <linux/delay.h> 2490b8fc34SJaya Kumar #include <linux/mtd/mtd.h> 2590b8fc34SJaya Kumar #include <linux/mtd/partitions.h> 26d8ad7859SJaya Kumar #include <linux/gpio.h> 27d8ad7859SJaya Kumar #include <linux/err.h> 28d8ad7859SJaya 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> 4151c62982SEric Miao 4251c62982SEric Miao #include <mach/pxa25x.h> 43a09e64fbSRussell King #include <mach/mmc.h> 44a09e64fbSRussell King #include <mach/udc.h> 45a09e64fbSRussell King #include <mach/gumstix.h> 4690b8fc34SJaya Kumar 4790b8fc34SJaya Kumar #include "generic.h" 4890b8fc34SJaya Kumar 4990b8fc34SJaya Kumar static struct resource flash_resource = { 5090b8fc34SJaya Kumar .start = 0x00000000, 5190b8fc34SJaya Kumar .end = SZ_64M - 1, 5290b8fc34SJaya Kumar .flags = IORESOURCE_MEM, 5390b8fc34SJaya Kumar }; 5490b8fc34SJaya Kumar 5590b8fc34SJaya Kumar static struct mtd_partition gumstix_partitions[] = { 5690b8fc34SJaya Kumar { 5790b8fc34SJaya Kumar .name = "Bootloader", 5890b8fc34SJaya Kumar .size = 0x00040000, 5990b8fc34SJaya Kumar .offset = 0, 6090b8fc34SJaya Kumar .mask_flags = MTD_WRITEABLE /* force read-only */ 6190b8fc34SJaya Kumar } , { 6290b8fc34SJaya Kumar .name = "rootfs", 6390b8fc34SJaya Kumar .size = MTDPART_SIZ_FULL, 6490b8fc34SJaya Kumar .offset = MTDPART_OFS_APPEND 6590b8fc34SJaya Kumar } 6690b8fc34SJaya Kumar }; 6790b8fc34SJaya Kumar 6890b8fc34SJaya Kumar static struct flash_platform_data gumstix_flash_data = { 6990b8fc34SJaya Kumar .map_name = "cfi_probe", 7090b8fc34SJaya Kumar .parts = gumstix_partitions, 7190b8fc34SJaya Kumar .nr_parts = ARRAY_SIZE(gumstix_partitions), 7290b8fc34SJaya Kumar .width = 2, 7390b8fc34SJaya Kumar }; 7490b8fc34SJaya Kumar 7590b8fc34SJaya Kumar static struct platform_device gumstix_flash_device = { 7690b8fc34SJaya Kumar .name = "pxa2xx-flash", 7790b8fc34SJaya Kumar .id = 0, 7890b8fc34SJaya Kumar .dev = { 7990b8fc34SJaya Kumar .platform_data = &gumstix_flash_data, 8090b8fc34SJaya Kumar }, 8190b8fc34SJaya Kumar .resource = &flash_resource, 8290b8fc34SJaya Kumar .num_resources = 1, 8390b8fc34SJaya Kumar }; 8490b8fc34SJaya Kumar 8590b8fc34SJaya Kumar static struct platform_device *devices[] __initdata = { 8690b8fc34SJaya Kumar &gumstix_flash_device, 8790b8fc34SJaya Kumar }; 8890b8fc34SJaya Kumar 8990b8fc34SJaya Kumar #ifdef CONFIG_MMC_PXA 9090b8fc34SJaya Kumar static struct pxamci_platform_data gumstix_mci_platform_data = { 9190b8fc34SJaya Kumar .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 92*7a648256SRobert Jarzmik .gpio_card_detect = -1, 93*7a648256SRobert Jarzmik .gpio_card_ro = -1, 94*7a648256SRobert Jarzmik .gpio_power = -1, 9590b8fc34SJaya Kumar }; 9690b8fc34SJaya Kumar 9790b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 9890b8fc34SJaya Kumar { 9990b8fc34SJaya Kumar pxa_set_mci_info(&gumstix_mci_platform_data); 10090b8fc34SJaya Kumar } 10190b8fc34SJaya Kumar #else 10290b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 10390b8fc34SJaya Kumar { 104d8ad7859SJaya Kumar pr_debug("Gumstix mmc disabled\n"); 10590b8fc34SJaya Kumar } 10690b8fc34SJaya Kumar #endif 10790b8fc34SJaya Kumar 108d8ad7859SJaya Kumar #ifdef CONFIG_USB_GADGET_PXA25X 10990b8fc34SJaya Kumar static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = { 11090b8fc34SJaya Kumar .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, 11190b8fc34SJaya Kumar .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx, 11290b8fc34SJaya Kumar }; 11390b8fc34SJaya Kumar 11490b8fc34SJaya Kumar static void __init gumstix_udc_init(void) 11590b8fc34SJaya Kumar { 11690b8fc34SJaya Kumar pxa_set_udc_info(&gumstix_udc_info); 11790b8fc34SJaya Kumar } 11890b8fc34SJaya Kumar #else 11990b8fc34SJaya Kumar static void gumstix_udc_init(void) 12090b8fc34SJaya Kumar { 121d8ad7859SJaya Kumar pr_debug("Gumstix udc is disabled\n"); 12290b8fc34SJaya Kumar } 12390b8fc34SJaya Kumar #endif 12490b8fc34SJaya Kumar 125d8ad7859SJaya Kumar #ifdef CONFIG_BT 126d8ad7859SJaya Kumar /* Normally, the bootloader would have enabled this 32kHz clock but many 127d8ad7859SJaya Kumar ** boards still have u-boot 1.1.4 so we check if it has been turned on and 128d8ad7859SJaya Kumar ** if not, we turn it on with a warning message. */ 129d8ad7859SJaya Kumar static void gumstix_setup_bt_clock(void) 130d8ad7859SJaya Kumar { 131d8ad7859SJaya Kumar int timeout = 500; 132d8ad7859SJaya Kumar 133d8ad7859SJaya Kumar if (!(OSCC & OSCC_OOK)) 134d8ad7859SJaya Kumar pr_warning("32kHz clock was not on. Bootloader may need to " 135d8ad7859SJaya Kumar "be updated\n"); 136d8ad7859SJaya Kumar else 137d8ad7859SJaya Kumar return; 138d8ad7859SJaya Kumar 139d8ad7859SJaya Kumar OSCC |= OSCC_OON; 140d8ad7859SJaya Kumar do { 141d8ad7859SJaya Kumar if (OSCC & OSCC_OOK) 142d8ad7859SJaya Kumar break; 143d8ad7859SJaya Kumar udelay(1); 144d8ad7859SJaya Kumar } while (--timeout); 145d8ad7859SJaya Kumar if (!timeout) 146d8ad7859SJaya Kumar pr_err("Failed to start 32kHz clock\n"); 147d8ad7859SJaya Kumar } 148d8ad7859SJaya Kumar 149d8ad7859SJaya Kumar static void __init gumstix_bluetooth_init(void) 150d8ad7859SJaya Kumar { 151d8ad7859SJaya Kumar int err; 152d8ad7859SJaya Kumar 153d8ad7859SJaya Kumar gumstix_setup_bt_clock(); 154d8ad7859SJaya Kumar 155d8ad7859SJaya Kumar err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); 156d8ad7859SJaya Kumar if (err) { 157d8ad7859SJaya Kumar pr_err("gumstix: failed request gpio for bluetooth reset\n"); 158d8ad7859SJaya Kumar return; 159d8ad7859SJaya Kumar } 160d8ad7859SJaya Kumar 161d8ad7859SJaya Kumar err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); 162d8ad7859SJaya Kumar if (err) { 163d8ad7859SJaya Kumar pr_err("gumstix: can't reset bluetooth\n"); 164d8ad7859SJaya Kumar return; 165d8ad7859SJaya Kumar } 166d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); 167d8ad7859SJaya Kumar udelay(100); 168d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); 169d8ad7859SJaya Kumar } 170d8ad7859SJaya Kumar #else 171d8ad7859SJaya Kumar static void gumstix_bluetooth_init(void) 172d8ad7859SJaya Kumar { 173d8ad7859SJaya Kumar pr_debug("Gumstix Bluetooth is disabled\n"); 174d8ad7859SJaya Kumar } 175d8ad7859SJaya Kumar #endif 176d8ad7859SJaya Kumar 177d8ad7859SJaya Kumar static unsigned long gumstix_pin_config[] __initdata = { 178d8ad7859SJaya Kumar GPIO12_32KHz, 179d8ad7859SJaya Kumar /* BTUART */ 180d8ad7859SJaya Kumar GPIO42_HWUART_RXD, 181d8ad7859SJaya Kumar GPIO43_HWUART_TXD, 182d8ad7859SJaya Kumar GPIO44_HWUART_CTS, 183d8ad7859SJaya Kumar GPIO45_HWUART_RTS, 184d8ad7859SJaya Kumar /* MMC */ 185d8ad7859SJaya Kumar GPIO6_MMC_CLK, 186d8ad7859SJaya Kumar GPIO53_MMC_CLK, 187d8ad7859SJaya Kumar GPIO8_MMC_CS0, 188d8ad7859SJaya Kumar }; 189d8ad7859SJaya Kumar 1903332b0c1SJaya Kumar int __attribute__((weak)) am200_init(void) 1913332b0c1SJaya Kumar { 1923332b0c1SJaya Kumar return 0; 1933332b0c1SJaya Kumar } 1943332b0c1SJaya Kumar 1954ce255c1SJaya Kumar int __attribute__((weak)) am300_init(void) 1964ce255c1SJaya Kumar { 1974ce255c1SJaya Kumar return 0; 1984ce255c1SJaya Kumar } 1994ce255c1SJaya Kumar 2003332b0c1SJaya Kumar static void __init carrier_board_init(void) 2013332b0c1SJaya Kumar { 2023332b0c1SJaya Kumar /* 2033332b0c1SJaya Kumar * put carrier/expansion board init here if 2043332b0c1SJaya Kumar * they cannot be detected programatically 2053332b0c1SJaya Kumar */ 2063332b0c1SJaya Kumar am200_init(); 2074ce255c1SJaya Kumar am300_init(); 2083332b0c1SJaya Kumar } 2093332b0c1SJaya Kumar 21090b8fc34SJaya Kumar static void __init gumstix_init(void) 21190b8fc34SJaya Kumar { 212d8ad7859SJaya Kumar pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config)); 213d8ad7859SJaya Kumar 214d8ad7859SJaya Kumar gumstix_bluetooth_init(); 21590b8fc34SJaya Kumar gumstix_udc_init(); 21690b8fc34SJaya Kumar gumstix_mmc_init(); 21790b8fc34SJaya Kumar (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 2183332b0c1SJaya Kumar carrier_board_init(); 21990b8fc34SJaya Kumar } 22090b8fc34SJaya Kumar 22190b8fc34SJaya Kumar MACHINE_START(GUMSTIX, "Gumstix") 22290b8fc34SJaya Kumar .phys_io = 0x40000000, 22390b8fc34SJaya Kumar .boot_params = 0xa0000100, /* match u-boot bi_boot_params */ 22490b8fc34SJaya Kumar .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 22590b8fc34SJaya Kumar .map_io = pxa_map_io, 22690b8fc34SJaya Kumar .init_irq = pxa25x_init_irq, 22790b8fc34SJaya Kumar .timer = &pxa_timer, 22890b8fc34SJaya Kumar .init_machine = gumstix_init, 22990b8fc34SJaya Kumar MACHINE_END 230