1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 290b8fc34SJaya Kumar /* 390b8fc34SJaya Kumar * linux/arch/arm/mach-pxa/gumstix.c 490b8fc34SJaya Kumar * 590b8fc34SJaya Kumar * Support for the Gumstix motherboards. 690b8fc34SJaya Kumar * 790b8fc34SJaya Kumar * Original Author: Craig Hughes 890b8fc34SJaya Kumar * Created: Feb 14, 2008 990b8fc34SJaya Kumar * Copyright: Craig Hughes 1090b8fc34SJaya Kumar * 1190b8fc34SJaya Kumar * Implemented based on lubbock.c by Nicolas Pitre and code from Craig 1290b8fc34SJaya Kumar * Hughes 1390b8fc34SJaya Kumar */ 1490b8fc34SJaya Kumar 1590b8fc34SJaya Kumar #include <linux/module.h> 1690b8fc34SJaya Kumar #include <linux/kernel.h> 1790b8fc34SJaya Kumar #include <linux/init.h> 1890b8fc34SJaya Kumar #include <linux/platform_device.h> 1990b8fc34SJaya Kumar #include <linux/interrupt.h> 20d8ad7859SJaya Kumar #include <linux/delay.h> 2190b8fc34SJaya Kumar #include <linux/mtd/mtd.h> 2290b8fc34SJaya Kumar #include <linux/mtd/partitions.h> 23*fdabc466SLinus Walleij #include <linux/gpio/machine.h> 24d8ad7859SJaya Kumar #include <linux/gpio.h> 25d8ad7859SJaya Kumar #include <linux/err.h> 26d8ad7859SJaya Kumar #include <linux/clk.h> 2790b8fc34SJaya Kumar 2890b8fc34SJaya Kumar #include <asm/setup.h> 2990b8fc34SJaya Kumar #include <asm/memory.h> 3090b8fc34SJaya Kumar #include <asm/mach-types.h> 31a09e64fbSRussell King #include <mach/hardware.h> 3290b8fc34SJaya Kumar #include <asm/irq.h> 3387dfb311SMasahiro Yamada #include <linux/sizes.h> 3490b8fc34SJaya Kumar 3590b8fc34SJaya Kumar #include <asm/mach/arch.h> 3690b8fc34SJaya Kumar #include <asm/mach/map.h> 3790b8fc34SJaya Kumar #include <asm/mach/irq.h> 3890b8fc34SJaya Kumar #include <asm/mach/flash.h> 3951c62982SEric Miao 404c25c5d2SArnd Bergmann #include "pxa25x.h" 41293b2da1SArnd Bergmann #include <linux/platform_data/mmc-pxamci.h> 424c25c5d2SArnd Bergmann #include "udc.h" 434c25c5d2SArnd Bergmann #include "gumstix.h" 4490b8fc34SJaya Kumar 4590b8fc34SJaya Kumar #include "generic.h" 4690b8fc34SJaya Kumar 4790b8fc34SJaya Kumar static struct resource flash_resource = { 4890b8fc34SJaya Kumar .start = 0x00000000, 4990b8fc34SJaya Kumar .end = SZ_64M - 1, 5090b8fc34SJaya Kumar .flags = IORESOURCE_MEM, 5190b8fc34SJaya Kumar }; 5290b8fc34SJaya Kumar 5390b8fc34SJaya Kumar static struct mtd_partition gumstix_partitions[] = { 5490b8fc34SJaya Kumar { 5590b8fc34SJaya Kumar .name = "Bootloader", 5690b8fc34SJaya Kumar .size = 0x00040000, 5790b8fc34SJaya Kumar .offset = 0, 5890b8fc34SJaya Kumar .mask_flags = MTD_WRITEABLE /* force read-only */ 5990b8fc34SJaya Kumar } , { 6090b8fc34SJaya Kumar .name = "rootfs", 6190b8fc34SJaya Kumar .size = MTDPART_SIZ_FULL, 6290b8fc34SJaya Kumar .offset = MTDPART_OFS_APPEND 6390b8fc34SJaya Kumar } 6490b8fc34SJaya Kumar }; 6590b8fc34SJaya Kumar 6690b8fc34SJaya Kumar static struct flash_platform_data gumstix_flash_data = { 6790b8fc34SJaya Kumar .map_name = "cfi_probe", 6890b8fc34SJaya Kumar .parts = gumstix_partitions, 6990b8fc34SJaya Kumar .nr_parts = ARRAY_SIZE(gumstix_partitions), 7090b8fc34SJaya Kumar .width = 2, 7190b8fc34SJaya Kumar }; 7290b8fc34SJaya Kumar 7390b8fc34SJaya Kumar static struct platform_device gumstix_flash_device = { 7490b8fc34SJaya Kumar .name = "pxa2xx-flash", 7590b8fc34SJaya Kumar .id = 0, 7690b8fc34SJaya Kumar .dev = { 7790b8fc34SJaya Kumar .platform_data = &gumstix_flash_data, 7890b8fc34SJaya Kumar }, 7990b8fc34SJaya Kumar .resource = &flash_resource, 8090b8fc34SJaya Kumar .num_resources = 1, 8190b8fc34SJaya Kumar }; 8290b8fc34SJaya Kumar 8390b8fc34SJaya Kumar static struct platform_device *devices[] __initdata = { 8490b8fc34SJaya Kumar &gumstix_flash_device, 8590b8fc34SJaya Kumar }; 8690b8fc34SJaya Kumar 8790b8fc34SJaya Kumar #ifdef CONFIG_MMC_PXA 8890b8fc34SJaya Kumar static struct pxamci_platform_data gumstix_mci_platform_data = { 8990b8fc34SJaya Kumar .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 9090b8fc34SJaya Kumar }; 9190b8fc34SJaya Kumar 9290b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 9390b8fc34SJaya Kumar { 9490b8fc34SJaya Kumar pxa_set_mci_info(&gumstix_mci_platform_data); 9590b8fc34SJaya Kumar } 9690b8fc34SJaya Kumar #else 9790b8fc34SJaya Kumar static void __init gumstix_mmc_init(void) 9890b8fc34SJaya Kumar { 99d8ad7859SJaya Kumar pr_debug("Gumstix mmc disabled\n"); 10090b8fc34SJaya Kumar } 10190b8fc34SJaya Kumar #endif 10290b8fc34SJaya Kumar 103c0a39151SHaojian Zhuang #ifdef CONFIG_USB_PXA25X 104*fdabc466SLinus Walleij static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = { 105*fdabc466SLinus Walleij .dev_id = "gpio-vbus", 106*fdabc466SLinus Walleij .table = { 107*fdabc466SLinus Walleij GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn, 108*fdabc466SLinus Walleij "vbus", GPIO_ACTIVE_HIGH), 109*fdabc466SLinus Walleij GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx, 110*fdabc466SLinus Walleij "pullup", GPIO_ACTIVE_HIGH), 111*fdabc466SLinus Walleij { }, 112*fdabc466SLinus Walleij }, 11390b8fc34SJaya Kumar }; 11490b8fc34SJaya Kumar 115d19f4cbdSDmitry Eremin-Solenikov static struct platform_device gumstix_gpio_vbus = { 116d19f4cbdSDmitry Eremin-Solenikov .name = "gpio-vbus", 117d19f4cbdSDmitry Eremin-Solenikov .id = -1, 118d19f4cbdSDmitry Eremin-Solenikov }; 119d19f4cbdSDmitry Eremin-Solenikov 12090b8fc34SJaya Kumar static void __init gumstix_udc_init(void) 12190b8fc34SJaya Kumar { 122*fdabc466SLinus Walleij gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table); 123d19f4cbdSDmitry Eremin-Solenikov platform_device_register(&gumstix_gpio_vbus); 12490b8fc34SJaya Kumar } 12590b8fc34SJaya Kumar #else 12690b8fc34SJaya Kumar static void gumstix_udc_init(void) 12790b8fc34SJaya Kumar { 128d8ad7859SJaya Kumar pr_debug("Gumstix udc is disabled\n"); 12990b8fc34SJaya Kumar } 13090b8fc34SJaya Kumar #endif 13190b8fc34SJaya Kumar 132d8ad7859SJaya Kumar #ifdef CONFIG_BT 133d8ad7859SJaya Kumar /* Normally, the bootloader would have enabled this 32kHz clock but many 134d8ad7859SJaya Kumar ** boards still have u-boot 1.1.4 so we check if it has been turned on and 135d8ad7859SJaya Kumar ** if not, we turn it on with a warning message. */ 136d8ad7859SJaya Kumar static void gumstix_setup_bt_clock(void) 137d8ad7859SJaya Kumar { 138d8ad7859SJaya Kumar int timeout = 500; 139d8ad7859SJaya Kumar 140ea7743e2SArnd Bergmann if (!(readl(OSCC) & OSCC_OOK)) 1417b472ac7SJoe Perches pr_warn("32kHz clock was not on. Bootloader may need to be updated\n"); 142d8ad7859SJaya Kumar else 143d8ad7859SJaya Kumar return; 144d8ad7859SJaya Kumar 145ea7743e2SArnd Bergmann writel(readl(OSCC) | OSCC_OON, OSCC); 146d8ad7859SJaya Kumar do { 147ea7743e2SArnd Bergmann if (readl(OSCC) & OSCC_OOK) 148d8ad7859SJaya Kumar break; 149d8ad7859SJaya Kumar udelay(1); 150d8ad7859SJaya Kumar } while (--timeout); 151d8ad7859SJaya Kumar if (!timeout) 152d8ad7859SJaya Kumar pr_err("Failed to start 32kHz clock\n"); 153d8ad7859SJaya Kumar } 154d8ad7859SJaya Kumar 155d8ad7859SJaya Kumar static void __init gumstix_bluetooth_init(void) 156d8ad7859SJaya Kumar { 157d8ad7859SJaya Kumar int err; 158d8ad7859SJaya Kumar 159d8ad7859SJaya Kumar gumstix_setup_bt_clock(); 160d8ad7859SJaya Kumar 161d8ad7859SJaya Kumar err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); 162d8ad7859SJaya Kumar if (err) { 163d8ad7859SJaya Kumar pr_err("gumstix: failed request gpio for bluetooth reset\n"); 164d8ad7859SJaya Kumar return; 165d8ad7859SJaya Kumar } 166d8ad7859SJaya Kumar 167d8ad7859SJaya Kumar err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); 168d8ad7859SJaya Kumar if (err) { 169d8ad7859SJaya Kumar pr_err("gumstix: can't reset bluetooth\n"); 170d8ad7859SJaya Kumar return; 171d8ad7859SJaya Kumar } 172d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); 173d8ad7859SJaya Kumar udelay(100); 174d8ad7859SJaya Kumar gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); 175d8ad7859SJaya Kumar } 176d8ad7859SJaya Kumar #else 177d8ad7859SJaya Kumar static void gumstix_bluetooth_init(void) 178d8ad7859SJaya Kumar { 179d8ad7859SJaya Kumar pr_debug("Gumstix Bluetooth is disabled\n"); 180d8ad7859SJaya Kumar } 181d8ad7859SJaya Kumar #endif 182d8ad7859SJaya Kumar 183d8ad7859SJaya Kumar static unsigned long gumstix_pin_config[] __initdata = { 184d8ad7859SJaya Kumar GPIO12_32KHz, 185d8ad7859SJaya Kumar /* BTUART */ 186d8ad7859SJaya Kumar GPIO42_HWUART_RXD, 187d8ad7859SJaya Kumar GPIO43_HWUART_TXD, 188d8ad7859SJaya Kumar GPIO44_HWUART_CTS, 189d8ad7859SJaya Kumar GPIO45_HWUART_RTS, 190d8ad7859SJaya Kumar /* MMC */ 191d8ad7859SJaya Kumar GPIO6_MMC_CLK, 192d8ad7859SJaya Kumar GPIO53_MMC_CLK, 193d8ad7859SJaya Kumar GPIO8_MMC_CS0, 194d8ad7859SJaya Kumar }; 195d8ad7859SJaya Kumar 1963332b0c1SJaya Kumar int __attribute__((weak)) am200_init(void) 1973332b0c1SJaya Kumar { 1983332b0c1SJaya Kumar return 0; 1993332b0c1SJaya Kumar } 2003332b0c1SJaya Kumar 2014ce255c1SJaya Kumar int __attribute__((weak)) am300_init(void) 2024ce255c1SJaya Kumar { 2034ce255c1SJaya Kumar return 0; 2044ce255c1SJaya Kumar } 2054ce255c1SJaya Kumar 2063332b0c1SJaya Kumar static void __init carrier_board_init(void) 2073332b0c1SJaya Kumar { 2083332b0c1SJaya Kumar /* 2093332b0c1SJaya Kumar * put carrier/expansion board init here if 2103332b0c1SJaya Kumar * they cannot be detected programatically 2113332b0c1SJaya Kumar */ 2123332b0c1SJaya Kumar am200_init(); 2134ce255c1SJaya Kumar am300_init(); 2143332b0c1SJaya Kumar } 2153332b0c1SJaya Kumar 21690b8fc34SJaya Kumar static void __init gumstix_init(void) 21790b8fc34SJaya Kumar { 218d8ad7859SJaya Kumar pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config)); 219d8ad7859SJaya Kumar 220cc155c6fSRussell King pxa_set_ffuart_info(NULL); 221cc155c6fSRussell King pxa_set_btuart_info(NULL); 222cc155c6fSRussell King pxa_set_stuart_info(NULL); 223cc155c6fSRussell King pxa_set_hwuart_info(NULL); 224cc155c6fSRussell King 225d8ad7859SJaya Kumar gumstix_bluetooth_init(); 22690b8fc34SJaya Kumar gumstix_udc_init(); 22790b8fc34SJaya Kumar gumstix_mmc_init(); 22890b8fc34SJaya Kumar (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 2293332b0c1SJaya Kumar carrier_board_init(); 23090b8fc34SJaya Kumar } 23190b8fc34SJaya Kumar 23290b8fc34SJaya Kumar MACHINE_START(GUMSTIX, "Gumstix") 2337375aba6SNicolas Pitre .atag_offset = 0x100, /* match u-boot bi_boot_params */ 234851982c1SMarek Vasut .map_io = pxa25x_map_io, 2354e611091SRob Herring .nr_irqs = PXA_NR_IRQS, 23690b8fc34SJaya Kumar .init_irq = pxa25x_init_irq, 2378a97ae2fSEric Miao .handle_irq = pxa25x_handle_irq, 2386bb27d73SStephen Warren .init_time = pxa_timer_init, 23990b8fc34SJaya Kumar .init_machine = gumstix_init, 240271a74fcSRussell King .restart = pxa_restart, 24190b8fc34SJaya Kumar MACHINE_END 242