Linux 4.19.133
[linux/fpc-iii.git] / drivers / mfd / tmio_core.c
blobebf54cc28f7a740996671775b6a10a64ff50e225
1 /*
2 * Copyright(c) 2009 Ian Molton <spyro@f2s.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include <linux/export.h>
10 #include <linux/mfd/tmio.h>
12 #define CNF_CMD 0x04
13 #define CNF_CTL_BASE 0x10
14 #define CNF_INT_PIN 0x3d
15 #define CNF_STOP_CLK_CTL 0x40
16 #define CNF_GCLK_CTL 0x41
17 #define CNF_SD_CLK_MODE 0x42
18 #define CNF_PIN_STATUS 0x44
19 #define CNF_PWR_CTL_1 0x48
20 #define CNF_PWR_CTL_2 0x49
21 #define CNF_PWR_CTL_3 0x4a
22 #define CNF_CARD_DETECT_MODE 0x4c
23 #define CNF_SD_SLOT 0x50
24 #define CNF_EXT_GCLK_CTL_1 0xf0
25 #define CNF_EXT_GCLK_CTL_2 0xf1
26 #define CNF_EXT_GCLK_CTL_3 0xf9
27 #define CNF_SD_LED_EN_1 0xfa
28 #define CNF_SD_LED_EN_2 0xfe
30 #define SDCREN 0x2 /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/
32 int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
34 /* Enable the MMC/SD Control registers */
35 sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
36 sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
38 /* Disable SD power during suspend */
39 sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
41 /* The below is required but why? FIXME */
42 sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
44 /* Power down SD bus */
45 sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
47 return 0;
49 EXPORT_SYMBOL(tmio_core_mmc_enable);
51 int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
54 /* Enable the MMC/SD Control registers */
55 sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
56 sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
58 return 0;
60 EXPORT_SYMBOL(tmio_core_mmc_resume);
62 void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
64 sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
66 EXPORT_SYMBOL(tmio_core_mmc_pwr);
68 void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
70 sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
72 EXPORT_SYMBOL(tmio_core_mmc_clk_div);