^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * arch/arm/mach-ep93xx/simone.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Simplemachines Sim.One support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2010 Ryan Mallon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Based on the 2.6.24.7 support:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (C) 2009 Simplemachines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * MMC support by Peter Ivanov <ivanovp@gmail.com>, 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mmc/host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/spi/spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/spi/mmc_spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/platform_data/video-ep93xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/platform_data/spi-ep93xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "hardware.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "gpio-ep93xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "soc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static struct ep93xx_eth_data __initdata simone_eth_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .phy_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static struct ep93xxfb_mach_info __initdata simone_fb_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .flags = EP93XXFB_USE_SDCSN0 | EP93XXFB_PCLK_FALLING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct mmc_spi_platform_data simone_mmc_spi_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .detect_delay = 500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static struct gpiod_lookup_table simone_mmc_spi_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) .dev_id = "mmc_spi.0", /* "mmc_spi" @ CS0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Card detect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) GPIO_LOOKUP_IDX("A", 0, NULL, 0, GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static struct spi_board_info simone_spi_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .modalias = "mmc_spi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .platform_data = &simone_mmc_spi_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * We use 10 MHz even though the maximum is 3.7 MHz. The driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * will limit it automatically to max. frequency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .max_speed_hz = 10 * 1000 * 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) .bus_num = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .chip_select = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .mode = SPI_MODE_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * Up to v1.3, the Sim.One used SFRMOUT as SD card chip select, but this goes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * low between multi-message command blocks. From v1.4, it uses a GPIO instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * v1.3 parts will still work, since the signal on SFRMOUT is automatic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static struct gpiod_lookup_table simone_spi_cs_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .dev_id = "spi0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) GPIO_LOOKUP("A", 1, "cs", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static struct ep93xx_spi_info simone_spi_info __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .use_dma = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static struct i2c_board_info __initdata simone_i2c_board_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) I2C_BOARD_INFO("ds1337", 0x68),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static struct platform_device simone_audio_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .name = "simone-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static void __init simone_register_audio(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ep93xx_register_ac97();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) platform_device_register(&simone_audio_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static void __init simone_init_machine(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ep93xx_init_devices();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_8M);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ep93xx_register_eth(&simone_eth_data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ep93xx_register_fb(&simone_fb_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ep93xx_register_i2c(simone_i2c_board_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ARRAY_SIZE(simone_i2c_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) gpiod_add_lookup_table(&simone_mmc_spi_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) gpiod_add_lookup_table(&simone_spi_cs_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) ep93xx_register_spi(&simone_spi_info, simone_spi_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ARRAY_SIZE(simone_spi_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) simone_register_audio();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* Maintainer: Ryan Mallon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) .map_io = ep93xx_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) .init_irq = ep93xx_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) .init_time = ep93xx_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .init_machine = simone_init_machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .init_late = ep93xx_init_late,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .restart = ep93xx_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) MACHINE_END