Linux Audio

Check our new training course

Loading...
v5.9
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * Copyright(c) 2009 Ian Molton <spyro@f2s.com>
 
 
 
 
 4 */
 5
 6#include <linux/export.h>
 7#include <linux/mfd/tmio.h>
 8
 9#define CNF_CMD     0x04
10#define CNF_CTL_BASE   0x10
11#define CNF_INT_PIN  0x3d
12#define CNF_STOP_CLK_CTL 0x40
13#define CNF_GCLK_CTL 0x41
14#define CNF_SD_CLK_MODE 0x42
15#define CNF_PIN_STATUS 0x44
16#define CNF_PWR_CTL_1 0x48
17#define CNF_PWR_CTL_2 0x49
18#define CNF_PWR_CTL_3 0x4a
19#define CNF_CARD_DETECT_MODE 0x4c
20#define CNF_SD_SLOT 0x50
21#define CNF_EXT_GCLK_CTL_1 0xf0
22#define CNF_EXT_GCLK_CTL_2 0xf1
23#define CNF_EXT_GCLK_CTL_3 0xf9
24#define CNF_SD_LED_EN_1 0xfa
25#define CNF_SD_LED_EN_2 0xfe
26
27#define   SDCREN 0x2   /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/
28
29int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
30{
31	/* Enable the MMC/SD Control registers */
32	sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
33	sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
34
35	/* Disable SD power during suspend */
36	sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
37
38	/* The below is required but why? FIXME */
39	sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
40
41	/* Power down SD bus */
42	sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
43
44	return 0;
45}
46EXPORT_SYMBOL(tmio_core_mmc_enable);
47
48int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
49{
50
51	/* Enable the MMC/SD Control registers */
52	sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
53	sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
54
55	return 0;
56}
57EXPORT_SYMBOL(tmio_core_mmc_resume);
58
59void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
60{
61	sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
62}
63EXPORT_SYMBOL(tmio_core_mmc_pwr);
64
65void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
66{
67	sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
68}
69EXPORT_SYMBOL(tmio_core_mmc_clk_div);
70
v3.15
 
 1/*
 2 * Copyright(c) 2009 Ian Molton <spyro@f2s.com>
 3 *
 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 */
 8
 9#include <linux/export.h>
10#include <linux/mfd/tmio.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base)
13{
14	/* Enable the MMC/SD Control registers */
15	sd_config_write16(cnf, shift, CNF_CMD, SDCREN);
16	sd_config_write32(cnf, shift, CNF_CTL_BASE, base & 0xfffe);
17
18	/* Disable SD power during suspend */
19	sd_config_write8(cnf, shift, CNF_PWR_CTL_3, 0x01);
20
21	/* The below is required but why? FIXME */
22	sd_config_write8(cnf, shift, CNF_STOP_CLK_CTL, 0x1f);
23
24	/* Power down SD bus */
25	sd_config_write8(cnf, shift, CNF_PWR_CTL_2, 0x00);
26
27	return 0;
28}
29EXPORT_SYMBOL(tmio_core_mmc_enable);
30
31int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base)
32{
33
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);
37
38	return 0;
39}
40EXPORT_SYMBOL(tmio_core_mmc_resume);
41
42void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state)
43{
44	sd_config_write8(cnf, shift, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
45}
46EXPORT_SYMBOL(tmio_core_mmc_pwr);
47
48void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state)
49{
50	sd_config_write8(cnf, shift, CNF_SD_CLK_MODE, state ? 1 : 0);
51}
52EXPORT_SYMBOL(tmio_core_mmc_clk_div);
53