1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
263138812SKalle Valo /*
363138812SKalle Valo * linux/arch/arm/mach-omap2/board-n8x0.c
463138812SKalle Valo *
563138812SKalle Valo * Copyright (C) 2005-2009 Nokia Corporation
663138812SKalle Valo * Author: Juha Yrjola <juha.yrjola@nokia.com>
763138812SKalle Valo *
863138812SKalle Valo * Modified from mach-omap2/board-generic.c
963138812SKalle Valo */
1063138812SKalle Valo
1163138812SKalle Valo #include <linux/clk.h>
1263138812SKalle Valo #include <linux/delay.h>
13e519f0bbSLinus Walleij #include <linux/gpio/machine.h>
148e0285abSLinus Walleij #include <linux/gpio/consumer.h>
1563138812SKalle Valo #include <linux/init.h>
1663138812SKalle Valo #include <linux/io.h>
170857ba3cSAaro Koskinen #include <linux/irq.h>
1863138812SKalle Valo #include <linux/stddef.h>
199418c65fSTony Lindgren #include <linux/i2c.h>
2063138812SKalle Valo #include <linux/spi/spi.h>
2163138812SKalle Valo #include <linux/usb/musb.h>
22826c71a0SAndreas Fenkart #include <linux/mmc/host.h>
232203747cSArnd Bergmann #include <linux/platform_data/spi-omap2-mcspi.h>
24826c71a0SAndreas Fenkart #include <linux/platform_data/mmc-omap.h>
257bd3b618STony Lindgren #include <linux/mfd/menelaus.h>
2663138812SKalle Valo
2763138812SKalle Valo #include <asm/mach/arch.h>
2863138812SKalle Valo #include <asm/mach-types.h>
2963138812SKalle Valo
304e65331cSTony Lindgren #include "common.h"
3168f39e74STony Lindgren #include "mmc.h"
328e0285abSLinus Walleij #include "usb-tusb6010.h"
33810ac2a1STony Lindgren #include "soc.h"
34e92ce89cSFelipe Balbi #include "common-board-devices.h"
35bd8f0fc9STony Lindgren
3697b9ad16SFrancisco Alecrim #define TUSB6010_ASYNC_CS 1
3797b9ad16SFrancisco Alecrim #define TUSB6010_SYNC_CS 4
3897b9ad16SFrancisco Alecrim #define TUSB6010_DMACHAN 0x3f
3997b9ad16SFrancisco Alecrim
40c8f27e97STony Lindgren #define NOKIA_N810_WIMAX (1 << 2)
41c8f27e97STony Lindgren #define NOKIA_N810 (1 << 1)
42c8f27e97STony Lindgren #define NOKIA_N800 (1 << 0)
43c8f27e97STony Lindgren
44c8f27e97STony Lindgren static u32 board_caps;
45c8f27e97STony Lindgren
46c8f27e97STony Lindgren #define board_is_n800() (board_caps & NOKIA_N800)
47c8f27e97STony Lindgren #define board_is_n810() (board_caps & NOKIA_N810)
48c8f27e97STony Lindgren #define board_is_n810_wimax() (board_caps & NOKIA_N810_WIMAX)
49c8f27e97STony Lindgren
board_check_revision(void)50c8f27e97STony Lindgren static void board_check_revision(void)
51c8f27e97STony Lindgren {
52c8f27e97STony Lindgren if (of_machine_is_compatible("nokia,n800"))
53c8f27e97STony Lindgren board_caps = NOKIA_N800;
54c8f27e97STony Lindgren else if (of_machine_is_compatible("nokia,n810"))
55c8f27e97STony Lindgren board_caps = NOKIA_N810;
56c8f27e97STony Lindgren else if (of_machine_is_compatible("nokia,n810-wimax"))
57c8f27e97STony Lindgren board_caps = NOKIA_N810_WIMAX;
58c8f27e97STony Lindgren
59c8f27e97STony Lindgren if (!board_caps)
60c8f27e97STony Lindgren pr_err("Unknown board\n");
61c8f27e97STony Lindgren }
62c8f27e97STony Lindgren
63502ad2a6SJavier Martinez Canillas #if IS_ENABLED(CONFIG_USB_MUSB_TUSB6010)
6497b9ad16SFrancisco Alecrim
6597b9ad16SFrancisco Alecrim static struct musb_hdrc_config musb_config = {
6697b9ad16SFrancisco Alecrim .multipoint = 1,
6797b9ad16SFrancisco Alecrim .dyn_fifo = 1,
6897b9ad16SFrancisco Alecrim .num_eps = 16,
6997b9ad16SFrancisco Alecrim .ram_bits = 12,
7097b9ad16SFrancisco Alecrim };
7197b9ad16SFrancisco Alecrim
7297b9ad16SFrancisco Alecrim static struct musb_hdrc_platform_data tusb_data = {
7397b9ad16SFrancisco Alecrim .mode = MUSB_OTG,
7497b9ad16SFrancisco Alecrim .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
7597b9ad16SFrancisco Alecrim .power = 100, /* Max 100 mA VBUS for host mode */
7697b9ad16SFrancisco Alecrim .config = &musb_config,
7797b9ad16SFrancisco Alecrim };
7897b9ad16SFrancisco Alecrim
798e0285abSLinus Walleij static struct gpiod_lookup_table tusb_gpio_table = {
808e0285abSLinus Walleij .dev_id = "musb-tusb",
818e0285abSLinus Walleij .table = {
82*6f9a8a54SAaro Koskinen GPIO_LOOKUP("gpio-0-31", 0, "enable", GPIO_ACTIVE_HIGH),
83*6f9a8a54SAaro Koskinen GPIO_LOOKUP("gpio-32-63", 26, "int", GPIO_ACTIVE_HIGH),
848e0285abSLinus Walleij { }
858e0285abSLinus Walleij },
868e0285abSLinus Walleij };
878e0285abSLinus Walleij
n8x0_usb_init(void)8897b9ad16SFrancisco Alecrim static void __init n8x0_usb_init(void)
8997b9ad16SFrancisco Alecrim {
9097b9ad16SFrancisco Alecrim int ret = 0;
9197b9ad16SFrancisco Alecrim
928e0285abSLinus Walleij gpiod_add_lookup_table(&tusb_gpio_table);
9397b9ad16SFrancisco Alecrim ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
9497b9ad16SFrancisco Alecrim TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
958e0285abSLinus Walleij TUSB6010_DMACHAN);
9697b9ad16SFrancisco Alecrim if (ret != 0)
9797b9ad16SFrancisco Alecrim return;
9897b9ad16SFrancisco Alecrim
998e0285abSLinus Walleij pr_info("TUSB 6010\n");
1008e0285abSLinus Walleij
1018e0285abSLinus Walleij return;
10297b9ad16SFrancisco Alecrim }
10397b9ad16SFrancisco Alecrim #else
10497b9ad16SFrancisco Alecrim
n8x0_usb_init(void)10597b9ad16SFrancisco Alecrim static void __init n8x0_usb_init(void) {}
10697b9ad16SFrancisco Alecrim
1077c925546SFelipe Balbi #endif /*CONFIG_USB_MUSB_TUSB6010 */
10897b9ad16SFrancisco Alecrim
10997b9ad16SFrancisco Alecrim
11063138812SKalle Valo static struct omap2_mcspi_device_config p54spi_mcspi_config = {
11163138812SKalle Valo .turbo_mode = 0,
11263138812SKalle Valo };
11363138812SKalle Valo
11463138812SKalle Valo static struct spi_board_info n800_spi_board_info[] __initdata = {
11563138812SKalle Valo {
11663138812SKalle Valo .modalias = "p54spi",
11763138812SKalle Valo .bus_num = 2,
11863138812SKalle Valo .chip_select = 0,
11963138812SKalle Valo .max_speed_hz = 48000000,
12063138812SKalle Valo .controller_data = &p54spi_mcspi_config,
12163138812SKalle Valo },
12263138812SKalle Valo };
12363138812SKalle Valo
124502ad2a6SJavier Martinez Canillas #if defined(CONFIG_MENELAUS) && IS_ENABLED(CONFIG_MMC_OMAP)
1259418c65fSTony Lindgren
1269418c65fSTony Lindgren /*
1279418c65fSTony Lindgren * On both N800 and N810, only the first of the two MMC controllers is in use.
1289418c65fSTony Lindgren * The two MMC slots are multiplexed via Menelaus companion chip over I2C.
1299418c65fSTony Lindgren * On N800, both slots are powered via Menelaus. On N810, only one of the
1309418c65fSTony Lindgren * slots is powered via Menelaus. The N810 EMMC is powered via GPIO.
1319418c65fSTony Lindgren *
1329418c65fSTony Lindgren * VMMC slot 1 on both N800 and N810
1339418c65fSTony Lindgren * VDCDC3_APE and VMCS2_APE slot 2 on N800
1349418c65fSTony Lindgren * GPIO23 and GPIO9 slot 2 EMMC on N810
1359418c65fSTony Lindgren *
1369418c65fSTony Lindgren */
13749b87c6dSTony Lindgren static int slot1_cover_open;
13849b87c6dSTony Lindgren static int slot2_cover_open;
13949b87c6dSTony Lindgren static struct device *mmc_device;
14049b87c6dSTony Lindgren
141086426dcSAaro Koskinen static struct gpiod_lookup_table nokia800_mmc_gpio_table = {
142e519f0bbSLinus Walleij .dev_id = "mmci-omap.0",
143e519f0bbSLinus Walleij .table = {
144e519f0bbSLinus Walleij /* Slot switch, GPIO 96 */
145d73e7fb9SAaro Koskinen GPIO_LOOKUP("gpio-96-127", 0, "switch", GPIO_ACTIVE_HIGH),
146e519f0bbSLinus Walleij { }
147e519f0bbSLinus Walleij },
148e519f0bbSLinus Walleij };
149e519f0bbSLinus Walleij
150e519f0bbSLinus Walleij static struct gpiod_lookup_table nokia810_mmc_gpio_table = {
151e519f0bbSLinus Walleij .dev_id = "mmci-omap.0",
152e519f0bbSLinus Walleij .table = {
153086426dcSAaro Koskinen /* Slot switch, GPIO 96 */
154086426dcSAaro Koskinen GPIO_LOOKUP("gpio-96-127", 0, "switch", GPIO_ACTIVE_HIGH),
155e519f0bbSLinus Walleij /* Slot index 1, VSD power, GPIO 23 */
156d73e7fb9SAaro Koskinen GPIO_LOOKUP_IDX("gpio-0-31", 23, "vsd", 1, GPIO_ACTIVE_HIGH),
157e519f0bbSLinus Walleij /* Slot index 1, VIO power, GPIO 9 */
158d73e7fb9SAaro Koskinen GPIO_LOOKUP_IDX("gpio-0-31", 9, "vio", 1, GPIO_ACTIVE_HIGH),
159e519f0bbSLinus Walleij { }
160e519f0bbSLinus Walleij },
161e519f0bbSLinus Walleij };
1629418c65fSTony Lindgren
n8x0_mmc_set_power_menelaus(struct device * dev,int slot,int power_on,int vdd)1639418c65fSTony Lindgren static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
1649418c65fSTony Lindgren int power_on, int vdd)
1659418c65fSTony Lindgren {
1669418c65fSTony Lindgren int mV;
1679418c65fSTony Lindgren
1689418c65fSTony Lindgren #ifdef CONFIG_MMC_DEBUG
1699418c65fSTony Lindgren dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
1709418c65fSTony Lindgren power_on ? "on" : "off", vdd);
1719418c65fSTony Lindgren #endif
1729418c65fSTony Lindgren if (slot == 0) {
1739418c65fSTony Lindgren if (!power_on)
1749418c65fSTony Lindgren return menelaus_set_vmmc(0);
1759418c65fSTony Lindgren switch (1 << vdd) {
1769418c65fSTony Lindgren case MMC_VDD_33_34:
1779418c65fSTony Lindgren case MMC_VDD_32_33:
1789418c65fSTony Lindgren case MMC_VDD_31_32:
1799418c65fSTony Lindgren mV = 3100;
1809418c65fSTony Lindgren break;
1819418c65fSTony Lindgren case MMC_VDD_30_31:
1829418c65fSTony Lindgren mV = 3000;
1839418c65fSTony Lindgren break;
1849418c65fSTony Lindgren case MMC_VDD_28_29:
1859418c65fSTony Lindgren mV = 2800;
1869418c65fSTony Lindgren break;
1879418c65fSTony Lindgren case MMC_VDD_165_195:
1889418c65fSTony Lindgren mV = 1850;
1899418c65fSTony Lindgren break;
1909418c65fSTony Lindgren default:
1919418c65fSTony Lindgren BUG();
1929418c65fSTony Lindgren }
1939418c65fSTony Lindgren return menelaus_set_vmmc(mV);
1949418c65fSTony Lindgren } else {
1959418c65fSTony Lindgren if (!power_on)
1969418c65fSTony Lindgren return menelaus_set_vdcdc(3, 0);
1979418c65fSTony Lindgren switch (1 << vdd) {
1989418c65fSTony Lindgren case MMC_VDD_33_34:
1999418c65fSTony Lindgren case MMC_VDD_32_33:
2009418c65fSTony Lindgren mV = 3300;
2019418c65fSTony Lindgren break;
2029418c65fSTony Lindgren case MMC_VDD_30_31:
2039418c65fSTony Lindgren case MMC_VDD_29_30:
2049418c65fSTony Lindgren mV = 3000;
2059418c65fSTony Lindgren break;
2069418c65fSTony Lindgren case MMC_VDD_28_29:
2079418c65fSTony Lindgren case MMC_VDD_27_28:
2089418c65fSTony Lindgren mV = 2800;
2099418c65fSTony Lindgren break;
2109418c65fSTony Lindgren case MMC_VDD_24_25:
2119418c65fSTony Lindgren case MMC_VDD_23_24:
2129418c65fSTony Lindgren mV = 2400;
2139418c65fSTony Lindgren break;
2149418c65fSTony Lindgren case MMC_VDD_22_23:
2159418c65fSTony Lindgren case MMC_VDD_21_22:
2169418c65fSTony Lindgren mV = 2200;
2179418c65fSTony Lindgren break;
2189418c65fSTony Lindgren case MMC_VDD_20_21:
2199418c65fSTony Lindgren mV = 2000;
2209418c65fSTony Lindgren break;
2219418c65fSTony Lindgren case MMC_VDD_165_195:
2229418c65fSTony Lindgren mV = 1800;
2239418c65fSTony Lindgren break;
2249418c65fSTony Lindgren default:
2259418c65fSTony Lindgren BUG();
2269418c65fSTony Lindgren }
2279418c65fSTony Lindgren return menelaus_set_vdcdc(3, mV);
2289418c65fSTony Lindgren }
2299418c65fSTony Lindgren return 0;
2309418c65fSTony Lindgren }
2319418c65fSTony Lindgren
n8x0_mmc_set_power(struct device * dev,int slot,int power_on,int vdd)2329418c65fSTony Lindgren static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on,
2339418c65fSTony Lindgren int vdd)
2349418c65fSTony Lindgren {
235c8f27e97STony Lindgren if (board_is_n800() || slot == 0)
2369418c65fSTony Lindgren return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd);
2379418c65fSTony Lindgren
238e519f0bbSLinus Walleij /* The n810 power will be handled by GPIO code in the driver */
2399418c65fSTony Lindgren
2409418c65fSTony Lindgren return 0;
2419418c65fSTony Lindgren }
2429418c65fSTony Lindgren
n8x0_mmc_set_bus_mode(struct device * dev,int slot,int bus_mode)2439418c65fSTony Lindgren static int n8x0_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
2449418c65fSTony Lindgren {
2459418c65fSTony Lindgren int r;
2469418c65fSTony Lindgren
2479418c65fSTony Lindgren dev_dbg(dev, "Set slot %d bus mode %s\n", slot + 1,
2489418c65fSTony Lindgren bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
2499418c65fSTony Lindgren BUG_ON(slot != 0 && slot != 1);
2509418c65fSTony Lindgren slot++;
2519418c65fSTony Lindgren switch (bus_mode) {
2529418c65fSTony Lindgren case MMC_BUSMODE_OPENDRAIN:
2539418c65fSTony Lindgren r = menelaus_set_mmc_opendrain(slot, 1);
2549418c65fSTony Lindgren break;
2559418c65fSTony Lindgren case MMC_BUSMODE_PUSHPULL:
2569418c65fSTony Lindgren r = menelaus_set_mmc_opendrain(slot, 0);
2579418c65fSTony Lindgren break;
2589418c65fSTony Lindgren default:
2599418c65fSTony Lindgren BUG();
2609418c65fSTony Lindgren }
2619418c65fSTony Lindgren if (r != 0 && printk_ratelimit())
2629418c65fSTony Lindgren dev_err(dev, "MMC: unable to set bus mode for slot %d\n",
2639418c65fSTony Lindgren slot);
2649418c65fSTony Lindgren return r;
2659418c65fSTony Lindgren }
2669418c65fSTony Lindgren
n8x0_mmc_get_cover_state(struct device * dev,int slot)2679418c65fSTony Lindgren static int n8x0_mmc_get_cover_state(struct device *dev, int slot)
2689418c65fSTony Lindgren {
2699418c65fSTony Lindgren slot++;
2709418c65fSTony Lindgren BUG_ON(slot != 1 && slot != 2);
2719418c65fSTony Lindgren if (slot == 1)
2729418c65fSTony Lindgren return slot1_cover_open;
2739418c65fSTony Lindgren else
2749418c65fSTony Lindgren return slot2_cover_open;
2759418c65fSTony Lindgren }
2769418c65fSTony Lindgren
n8x0_mmc_callback(void * data,u8 card_mask)2779418c65fSTony Lindgren static void n8x0_mmc_callback(void *data, u8 card_mask)
2789418c65fSTony Lindgren {
279040ab72eSYongqiang Liu #ifdef CONFIG_MMC_OMAP
2809418c65fSTony Lindgren int bit, *openp, index;
2819418c65fSTony Lindgren
282c8f27e97STony Lindgren if (board_is_n800()) {
2839418c65fSTony Lindgren bit = 1 << 1;
2849418c65fSTony Lindgren openp = &slot2_cover_open;
2859418c65fSTony Lindgren index = 1;
2869418c65fSTony Lindgren } else {
2879418c65fSTony Lindgren bit = 1;
2889418c65fSTony Lindgren openp = &slot1_cover_open;
2899418c65fSTony Lindgren index = 0;
2909418c65fSTony Lindgren }
2919418c65fSTony Lindgren
2929418c65fSTony Lindgren if (card_mask & bit)
2939418c65fSTony Lindgren *openp = 1;
2949418c65fSTony Lindgren else
2959418c65fSTony Lindgren *openp = 0;
2969418c65fSTony Lindgren
2979418c65fSTony Lindgren omap_mmc_notify_cover_event(mmc_device, index, *openp);
298d5171102STony Lindgren #else
299d5171102STony Lindgren pr_warn("MMC: notify cover event not available\n");
300d5171102STony Lindgren #endif
3019418c65fSTony Lindgren }
3029418c65fSTony Lindgren
n8x0_mmc_late_init(struct device * dev)3039418c65fSTony Lindgren static int n8x0_mmc_late_init(struct device *dev)
3049418c65fSTony Lindgren {
3059418c65fSTony Lindgren int r, bit, *openp;
3069418c65fSTony Lindgren int vs2sel;
3079418c65fSTony Lindgren
3089418c65fSTony Lindgren mmc_device = dev;
3099418c65fSTony Lindgren
3109418c65fSTony Lindgren r = menelaus_set_slot_sel(1);
3119418c65fSTony Lindgren if (r < 0)
3129418c65fSTony Lindgren return r;
3139418c65fSTony Lindgren
314c8f27e97STony Lindgren if (board_is_n800())
3159418c65fSTony Lindgren vs2sel = 0;
3169418c65fSTony Lindgren else
3179418c65fSTony Lindgren vs2sel = 2;
3189418c65fSTony Lindgren
3199418c65fSTony Lindgren r = menelaus_set_mmc_slot(2, 0, vs2sel, 1);
3209418c65fSTony Lindgren if (r < 0)
3219418c65fSTony Lindgren return r;
3229418c65fSTony Lindgren
3239418c65fSTony Lindgren n8x0_mmc_set_power(dev, 0, MMC_POWER_ON, 16); /* MMC_VDD_28_29 */
3249418c65fSTony Lindgren n8x0_mmc_set_power(dev, 1, MMC_POWER_ON, 16);
3259418c65fSTony Lindgren
3269418c65fSTony Lindgren r = menelaus_set_mmc_slot(1, 1, 0, 1);
3279418c65fSTony Lindgren if (r < 0)
3289418c65fSTony Lindgren return r;
3299418c65fSTony Lindgren r = menelaus_set_mmc_slot(2, 1, vs2sel, 1);
3309418c65fSTony Lindgren if (r < 0)
3319418c65fSTony Lindgren return r;
3329418c65fSTony Lindgren
3339418c65fSTony Lindgren r = menelaus_get_slot_pin_states();
3349418c65fSTony Lindgren if (r < 0)
3359418c65fSTony Lindgren return r;
3369418c65fSTony Lindgren
337c8f27e97STony Lindgren if (board_is_n800()) {
3389418c65fSTony Lindgren bit = 1 << 1;
3399418c65fSTony Lindgren openp = &slot2_cover_open;
3409418c65fSTony Lindgren } else {
3419418c65fSTony Lindgren bit = 1;
3429418c65fSTony Lindgren openp = &slot1_cover_open;
3439418c65fSTony Lindgren slot2_cover_open = 0;
3449418c65fSTony Lindgren }
3459418c65fSTony Lindgren
3469418c65fSTony Lindgren /* All slot pin bits seem to be inversed until first switch change */
3479418c65fSTony Lindgren if (r == 0xf || r == (0xf & ~bit))
3489418c65fSTony Lindgren r = ~r;
3499418c65fSTony Lindgren
3509418c65fSTony Lindgren if (r & bit)
3519418c65fSTony Lindgren *openp = 1;
3529418c65fSTony Lindgren else
3539418c65fSTony Lindgren *openp = 0;
3549418c65fSTony Lindgren
3559418c65fSTony Lindgren r = menelaus_register_mmc_callback(n8x0_mmc_callback, NULL);
3569418c65fSTony Lindgren
3579418c65fSTony Lindgren return r;
3589418c65fSTony Lindgren }
3599418c65fSTony Lindgren
n8x0_mmc_shutdown(struct device * dev)3609418c65fSTony Lindgren static void n8x0_mmc_shutdown(struct device *dev)
3619418c65fSTony Lindgren {
3629418c65fSTony Lindgren int vs2sel;
3639418c65fSTony Lindgren
364c8f27e97STony Lindgren if (board_is_n800())
3659418c65fSTony Lindgren vs2sel = 0;
3669418c65fSTony Lindgren else
3679418c65fSTony Lindgren vs2sel = 2;
3689418c65fSTony Lindgren
3699418c65fSTony Lindgren menelaus_set_mmc_slot(1, 0, 0, 0);
3709418c65fSTony Lindgren menelaus_set_mmc_slot(2, 0, vs2sel, 0);
3719418c65fSTony Lindgren }
3729418c65fSTony Lindgren
n8x0_mmc_cleanup(struct device * dev)3739418c65fSTony Lindgren static void n8x0_mmc_cleanup(struct device *dev)
3749418c65fSTony Lindgren {
3759418c65fSTony Lindgren menelaus_unregister_mmc_callback();
3769418c65fSTony Lindgren }
3779418c65fSTony Lindgren
3789418c65fSTony Lindgren /*
3799418c65fSTony Lindgren * MMC controller1 has two slots that are multiplexed via I2C.
3809418c65fSTony Lindgren * MMC controller2 is not in use.
3819418c65fSTony Lindgren */
3829418c65fSTony Lindgren static struct omap_mmc_platform_data mmc1_data = {
383fa590c92STony Lindgren .nr_slots = 0,
3849418c65fSTony Lindgren .init = n8x0_mmc_late_init,
3859418c65fSTony Lindgren .cleanup = n8x0_mmc_cleanup,
3869418c65fSTony Lindgren .shutdown = n8x0_mmc_shutdown,
3879418c65fSTony Lindgren .max_freq = 24000000,
3889418c65fSTony Lindgren .slots[0] = {
3899418c65fSTony Lindgren .wires = 4,
3909418c65fSTony Lindgren .set_power = n8x0_mmc_set_power,
3919418c65fSTony Lindgren .set_bus_mode = n8x0_mmc_set_bus_mode,
3929418c65fSTony Lindgren .get_cover_state = n8x0_mmc_get_cover_state,
3939418c65fSTony Lindgren .ocr_mask = MMC_VDD_165_195 | MMC_VDD_30_31 |
3949418c65fSTony Lindgren MMC_VDD_32_33 | MMC_VDD_33_34,
3959418c65fSTony Lindgren .name = "internal",
3969418c65fSTony Lindgren },
3979418c65fSTony Lindgren .slots[1] = {
3989418c65fSTony Lindgren .set_power = n8x0_mmc_set_power,
3999418c65fSTony Lindgren .set_bus_mode = n8x0_mmc_set_bus_mode,
4009418c65fSTony Lindgren .get_cover_state = n8x0_mmc_get_cover_state,
4019418c65fSTony Lindgren .ocr_mask = MMC_VDD_165_195 | MMC_VDD_20_21 |
4029418c65fSTony Lindgren MMC_VDD_21_22 | MMC_VDD_22_23 |
4039418c65fSTony Lindgren MMC_VDD_23_24 | MMC_VDD_24_25 |
4049418c65fSTony Lindgren MMC_VDD_27_28 | MMC_VDD_28_29 |
4059418c65fSTony Lindgren MMC_VDD_29_30 | MMC_VDD_30_31 |
4069418c65fSTony Lindgren MMC_VDD_32_33 | MMC_VDD_33_34,
4079418c65fSTony Lindgren .name = "external",
4089418c65fSTony Lindgren },
4099418c65fSTony Lindgren };
4109418c65fSTony Lindgren
4119418c65fSTony Lindgren static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
4129418c65fSTony Lindgren
n8x0_mmc_init(void)413bc593f5dSIgor Grinberg static void __init n8x0_mmc_init(void)
4149418c65fSTony Lindgren {
415c8f27e97STony Lindgren if (board_is_n810()) {
4169418c65fSTony Lindgren mmc1_data.slots[0].name = "external";
4179418c65fSTony Lindgren
4189418c65fSTony Lindgren /*
4199418c65fSTony Lindgren * Some Samsung Movinand chips do not like open-ended
4209418c65fSTony Lindgren * multi-block reads and fall to braind-dead state
4219418c65fSTony Lindgren * while doing so. Reducing the number of blocks in
4229418c65fSTony Lindgren * the transfer or delays in clock disable do not help
4239418c65fSTony Lindgren */
4249418c65fSTony Lindgren mmc1_data.slots[1].name = "internal";
4259418c65fSTony Lindgren mmc1_data.slots[1].ban_openended = 1;
426e519f0bbSLinus Walleij gpiod_add_lookup_table(&nokia810_mmc_gpio_table);
427086426dcSAaro Koskinen } else {
428086426dcSAaro Koskinen gpiod_add_lookup_table(&nokia800_mmc_gpio_table);
4299418c65fSTony Lindgren }
4309418c65fSTony Lindgren
431fa590c92STony Lindgren mmc1_data.nr_slots = 2;
4329418c65fSTony Lindgren mmc_data[0] = &mmc1_data;
4339418c65fSTony Lindgren }
4349418c65fSTony Lindgren #else
435fa590c92STony Lindgren static struct omap_mmc_platform_data mmc1_data;
n8x0_mmc_init(void)4366aeb51c1SArnd Bergmann static void __init n8x0_mmc_init(void)
4379418c65fSTony Lindgren {
4389418c65fSTony Lindgren }
4399418c65fSTony Lindgren #endif /* CONFIG_MMC_OMAP */
4409418c65fSTony Lindgren
4419418c65fSTony Lindgren #ifdef CONFIG_MENELAUS
4429418c65fSTony Lindgren
n8x0_auto_sleep_regulators(void)4439418c65fSTony Lindgren static int n8x0_auto_sleep_regulators(void)
4449418c65fSTony Lindgren {
4459418c65fSTony Lindgren u32 val;
4469418c65fSTony Lindgren int ret;
4479418c65fSTony Lindgren
4489418c65fSTony Lindgren val = EN_VPLL_SLEEP | EN_VMMC_SLEEP \
4499418c65fSTony Lindgren | EN_VAUX_SLEEP | EN_VIO_SLEEP \
4509418c65fSTony Lindgren | EN_VMEM_SLEEP | EN_DC3_SLEEP \
4519418c65fSTony Lindgren | EN_VC_SLEEP | EN_DC2_SLEEP;
4529418c65fSTony Lindgren
4539418c65fSTony Lindgren ret = menelaus_set_regulator_sleep(1, val);
4549418c65fSTony Lindgren if (ret < 0) {
4557852ec05SPaul Walmsley pr_err("Could not set regulators to sleep on menelaus: %u\n",
4567852ec05SPaul Walmsley ret);
4579418c65fSTony Lindgren return ret;
4589418c65fSTony Lindgren }
4599418c65fSTony Lindgren return 0;
4609418c65fSTony Lindgren }
4619418c65fSTony Lindgren
n8x0_auto_voltage_scale(void)4629418c65fSTony Lindgren static int n8x0_auto_voltage_scale(void)
4639418c65fSTony Lindgren {
4649418c65fSTony Lindgren int ret;
4659418c65fSTony Lindgren
4669418c65fSTony Lindgren ret = menelaus_set_vcore_hw(1400, 1050);
4679418c65fSTony Lindgren if (ret < 0) {
4687852ec05SPaul Walmsley pr_err("Could not set VCORE voltage on menelaus: %u\n", ret);
4699418c65fSTony Lindgren return ret;
4709418c65fSTony Lindgren }
4719418c65fSTony Lindgren return 0;
4729418c65fSTony Lindgren }
4739418c65fSTony Lindgren
n8x0_menelaus_late_init(struct device * dev)4749418c65fSTony Lindgren static int n8x0_menelaus_late_init(struct device *dev)
4759418c65fSTony Lindgren {
4769418c65fSTony Lindgren int ret;
4779418c65fSTony Lindgren
4789418c65fSTony Lindgren ret = n8x0_auto_voltage_scale();
4799418c65fSTony Lindgren if (ret < 0)
4809418c65fSTony Lindgren return ret;
4819418c65fSTony Lindgren ret = n8x0_auto_sleep_regulators();
4829418c65fSTony Lindgren if (ret < 0)
4839418c65fSTony Lindgren return ret;
4849418c65fSTony Lindgren return 0;
4859418c65fSTony Lindgren }
4869418c65fSTony Lindgren
487a7f97d25SJarkko Nikula #else
n8x0_menelaus_late_init(struct device * dev)488a7f97d25SJarkko Nikula static int n8x0_menelaus_late_init(struct device *dev)
4899418c65fSTony Lindgren {
490a7f97d25SJarkko Nikula return 0;
491a7f97d25SJarkko Nikula }
492a7f97d25SJarkko Nikula #endif
4939418c65fSTony Lindgren
494ef70b0bdSTony Lindgren struct menelaus_platform_data n8x0_menelaus_platform_data = {
4959418c65fSTony Lindgren .late_init = n8x0_menelaus_late_init,
4969418c65fSTony Lindgren };
4979418c65fSTony Lindgren
n8x0_late_initcall(void)498810ac2a1STony Lindgren static int __init n8x0_late_initcall(void)
499810ac2a1STony Lindgren {
500810ac2a1STony Lindgren if (!board_caps)
501810ac2a1STony Lindgren return -ENODEV;
502810ac2a1STony Lindgren
503810ac2a1STony Lindgren n8x0_mmc_init();
504810ac2a1STony Lindgren n8x0_usb_init();
505810ac2a1STony Lindgren
506810ac2a1STony Lindgren return 0;
507810ac2a1STony Lindgren }
508810ac2a1STony Lindgren omap_late_initcall(n8x0_late_initcall);
509810ac2a1STony Lindgren
510fa590c92STony Lindgren /*
511fa590c92STony Lindgren * Legacy init pdata init for n8x0. Note that we want to follow the
512fa590c92STony Lindgren * I2C bus numbering starting at 0 for device tree like other omaps.
513fa590c92STony Lindgren */
n8x0_legacy_init(void)514fa590c92STony Lindgren void * __init n8x0_legacy_init(void)
515fa590c92STony Lindgren {
516fa590c92STony Lindgren board_check_revision();
517fa590c92STony Lindgren spi_register_board_info(n800_spi_board_info,
518fa590c92STony Lindgren ARRAY_SIZE(n800_spi_board_info));
519fa590c92STony Lindgren return &mmc1_data;
520fa590c92STony Lindgren }
521