From: haojian.zhuang@gmail.com (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 2/4] ARM: pxa168: Add SDHCI support
Date: Tue, 20 Dec 2011 21:25:52 +0800 [thread overview]
Message-ID: <CAN1soZzzu56SiUa4z2NY0HdqieYTZvM0q-nq1QsnCBLkeD70mg@mail.gmail.com> (raw)
In-Reply-To: <1324386781-25271-1-git-send-email-tanmay.upadhyay@einfochips.com>
On Tue, Dec 20, 2011 at 9:13 PM, Tanmay Upadhyay
<tanmay.upadhyay@einfochips.com> wrote:
> v2 - clock register for SDHCI are not common across all MMP SoCs.
> ? ? So, move PXA168 implementation to pxa168.c
>
> v3 - sdhci-pxav1 driver code is merged with sdhci-pxav2. So, change
> ? ? the device name accordingly
> ? - start sdhci device numbering from 1 as other PXA168 devices
> ? ? does that
>
> v4 - Use different names for SD clock registers for PXA168 instead
> ? ? of redefining them in pxa168.c. Suggested by Haojian Zhuang
>
> Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@einfochips.com>
> Reviewed-by: Philip Rakity <prakity@marvell.com>
> ---
> ?arch/arm/mach-mmp/include/mach/pxa168.h ? ?| ? 20 ++++++++++++++
> ?arch/arm/mach-mmp/include/mach/regs-apmu.h | ? 40 ++++++++++++++-------------
> ?arch/arm/mach-mmp/pxa168.c ? ? ? ? ? ? ? ? | ? 39 +++++++++++++++++++++++++++
> ?3 files changed, 80 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm/mach-mmp/include/mach/pxa168.h b/arch/arm/mach-mmp/include/mach/pxa168.h
> index 7fb568d..a181608 100644
> --- a/arch/arm/mach-mmp/include/mach/pxa168.h
> +++ b/arch/arm/mach-mmp/include/mach/pxa168.h
> @@ -15,6 +15,7 @@ extern void pxa168_clear_keypad_wakeup(void);
> ?#include <plat/pxa27x_keypad.h>
> ?#include <mach/cputype.h>
> ?#include <linux/pxa168_eth.h>
> +#include <linux/platform_data/pxa_sdhci.h>
>
> ?extern struct pxa_device_desc pxa168_device_uart1;
> ?extern struct pxa_device_desc pxa168_device_uart2;
> @@ -34,6 +35,10 @@ extern struct pxa_device_desc pxa168_device_nand;
> ?extern struct pxa_device_desc pxa168_device_fb;
> ?extern struct pxa_device_desc pxa168_device_keypad;
> ?extern struct pxa_device_desc pxa168_device_eth;
> +extern struct pxa_device_desc pxa168_device_sdh1;
> +extern struct pxa_device_desc pxa168_device_sdh2;
> +extern struct pxa_device_desc pxa168_device_sdh3;
> +extern struct pxa_device_desc pxa168_device_sdh4;
>
> ?struct pxa168_usb_pdata {
> ? ? ? ?/* If NULL, default phy init routine for PXA168 would be called */
> @@ -132,4 +137,19 @@ static inline int pxa168_add_eth(struct pxa168_eth_platform_data *data)
> ?{
> ? ? ? ?return pxa_register_device(&pxa168_device_eth, data, sizeof(*data));
> ?}
> +
> +static inline int pxa168_add_sdh(int id, struct sdhci_pxa_platdata *data)
> +{
> + ? ? ? struct pxa_device_desc *d = NULL;
> +
> + ? ? ? switch (id) {
> + ? ? ? case 1: d = &pxa168_device_sdh1; break;
> + ? ? ? case 2: d = &pxa168_device_sdh2; break;
> + ? ? ? case 3: d = &pxa168_device_sdh3; break;
> + ? ? ? case 4: d = &pxa168_device_sdh4; break;
> + ? ? ? default:
> + ? ? ? ? ? ? ? return -EINVAL;
> + ? ? ? }
> + ? ? ? return pxa_register_device(d, data, sizeof(*data));
> +}
> ?#endif /* __ASM_MACH_PXA168_H */
> diff --git a/arch/arm/mach-mmp/include/mach/regs-apmu.h b/arch/arm/mach-mmp/include/mach/regs-apmu.h
> index 8447ac6..a84de77 100644
> --- a/arch/arm/mach-mmp/include/mach/regs-apmu.h
> +++ b/arch/arm/mach-mmp/include/mach/regs-apmu.h
> @@ -17,27 +17,29 @@
> ?#define APMU_REG(x) ? ?(APMU_VIRT_BASE + (x))
>
> ?/* Clock Reset Control */
> -#define APMU_IRE ? ? ? APMU_REG(0x048)
> -#define APMU_LCD ? ? ? APMU_REG(0x04c)
> -#define APMU_CCIC ? ? ?APMU_REG(0x050)
> -#define APMU_SDH0 ? ? ?APMU_REG(0x054)
> -#define APMU_SDH1 ? ? ?APMU_REG(0x058)
> -#define APMU_USB ? ? ? APMU_REG(0x05c)
> -#define APMU_NAND ? ? ?APMU_REG(0x060)
> -#define APMU_DMA ? ? ? APMU_REG(0x064)
> -#define APMU_GEU ? ? ? APMU_REG(0x068)
> -#define APMU_BUS ? ? ? APMU_REG(0x06c)
> -#define APMU_SDH2 ? ? ?APMU_REG(0x0e8)
> -#define APMU_SDH3 ? ? ?APMU_REG(0x0ec)
> -#define APMU_ETH ? ? ? APMU_REG(0x0fc)
> -
> -#define APMU_FNCLK_EN ?(1 << 4)
> -#define APMU_AXICLK_EN (1 << 3)
> -#define APMU_FNRST_DIS (1 << 1)
> -#define APMU_AXIRST_DIS ? ? ? ?(1 << 0)
> +#define APMU_IRE ? ? ? ? ? ? ? APMU_REG(0x048)
> +#define APMU_LCD ? ? ? ? ? ? ? APMU_REG(0x04c)
> +#define APMU_CCIC ? ? ? ? ? ? ?APMU_REG(0x050)
> +#define APMU_SDH0 ? ? ? ? ? ? ?APMU_REG(0x054)
> +#define APMU_SDH1 ? ? ? ? ? ? ?APMU_REG(0x058)
> +#define APMU_USB ? ? ? ? ? ? ? APMU_REG(0x05c)
> +#define APMU_NAND ? ? ? ? ? ? ?APMU_REG(0x060)
> +#define APMU_DMA ? ? ? ? ? ? ? APMU_REG(0x064)
> +#define APMU_GEU ? ? ? ? ? ? ? APMU_REG(0x068)
> +#define APMU_BUS ? ? ? ? ? ? ? APMU_REG(0x06c)
> +#define APMU_PXA168_SDH2 ? ? ? APMU_REG(0x0e0)
> +#define APMU_PXA168_SDH3 ? ? ? APMU_REG(0x0e4)
> +#define APMU_SDH2 ? ? ? ? ? ? ?APMU_REG(0x0e8)
> +#define APMU_SDH3 ? ? ? ? ? ? ?APMU_REG(0x0ec)
> +#define APMU_ETH ? ? ? ? ? ? ? APMU_REG(0x0fc)
> +
> +#define APMU_FNCLK_EN ? ? ? ? ?(1 << 4)
> +#define APMU_AXICLK_EN ? ? ? ? (1 << 3)
> +#define APMU_FNRST_DIS ? ? ? ? (1 << 1)
> +#define APMU_AXIRST_DIS ? ? ? ? ? ? ? ?(1 << 0)
>
> ?/* Wake Clear Register */
> -#define APMU_WAKE_CLR ?APMU_REG(0x07c)
> +#define APMU_WAKE_CLR ? ? ? ? ?APMU_REG(0x07c)
>
> ?#define APMU_PXA168_KP_WAKE_CLR ? ? ? ? ? ? ? ?(1 << 7)
> ?#define APMU_PXA168_CFI_WAKE_CLR ? ? ? (1 << 6)
> diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
> index 76ca15c..023659b 100644
> --- a/arch/arm/mach-mmp/pxa168.c
> +++ b/arch/arm/mach-mmp/pxa168.c
> @@ -65,6 +65,32 @@ void __init pxa168_init_irq(void)
> ? ? ? ?pxa168_init_gpio();
> ?}
>
> +static void sdh_clk_enable(struct clk *clk)
> +{
> + ? ? ? void __iomem *reg_offset = clk->clk_rst;
> +
> + ? ? ? /* Can't see any clean way to do this: Bits 3 & 0 in registers
> + ? ? ? ?* for host 0 & 2 should be set for host 1 & 3 also */
> + ? ? ? if (reg_offset == APMU_SDH0 || reg_offset == APMU_SDH1)
> + ? ? ? ? ? ? ? __raw_writel(__raw_readl(APMU_SDH0) | 0x9, APMU_SDH0);
> + ? ? ? if (reg_offset == APMU_PXA168_SDH2 || reg_offset == APMU_PXA168_SDH3)
> + ? ? ? ? ? ? ? __raw_writel(__raw_readl(APMU_PXA168_SDH2) | 0x9,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? APMU_PXA168_SDH2);
> +
> + ? ? ? __raw_writel(__raw_readl(clk->clk_rst) | clk->enable_val, clk->clk_rst);
> +}
> +
How about use the below code instead? I think we can avoid to check
register offset.
static void sdh0_clk_enable(struct clk *clk)
{
void __iomem *reg_offset = clk->clk_rst;
__raw_writel(__raw_readl(APMU_SDH0) | 0x9, APMU_SDH0);
__raw_writel(__raw_readl(clk->clk_rst) | clk->enable_val, clk->clk_rst);
}
static void sdh2_clk_enable(struct clk *clk)
{
void __iomem *reg_offset = clk->clk_rst;
__raw_writel(__raw_readl(APMU_PXA168_SDH2) | 0x9,
APMU_PXA168_SDH2);
__raw_writel(__raw_readl(clk->clk_rst) | clk->enable_val, clk->clk_rst);
}
struct clkops sdh0_clk_ops = {
.enable = sdh0_clk_enable,
.disable = sdh_clk_disable,
};
struct clkops sdh2_clk_ops = {
.enable = sdh2_clk_enable,
.disable = sdh_clk_disable,
};
static APMU_CLK_OPS(sdh1, SDH0, 0x12, 48000000, &sdh0_clk_ops);
static APMU_CLK_OPS(sdh2, SDH1, 0x12, 48000000, &sdh0_clk_ops);
static APMU_CLK_OPS(sdh3, PXA168_SDH2, 0x12, 48000000, &sdh2_clk_ops);
static APMU_CLK_OPS(sdh4, PXA168_SDH3, 0x12, 48000000, &sdh2_clk_ops);
> +static void sdh_clk_disable(struct clk *clk)
> +{
> + ? ? ? __raw_writel(__raw_readl(clk->clk_rst) & ~(clk->enable_val),
> + ? ? ? ? ? ? ? ? ? ? ? clk->clk_rst);
> +}
> +
> +struct clkops sdh_clk_ops = {
> + ? ? ? .enable ? ? ? ? = sdh_clk_enable,
> + ? ? ? .disable ? ? ? ?= sdh_clk_disable,
> +};
> +
> ?/* APB peripheral clocks */
> ?static APBC_CLK(uart1, PXA168_UART1, 1, 14745600);
> ?static APBC_CLK(uart2, PXA168_UART2, 1, 14745600);
> @@ -87,6 +113,11 @@ static APMU_CLK(lcd, LCD, 0x7f, 312000000);
> ?static APMU_CLK(eth, ETH, 0x09, 0);
> ?static APMU_CLK(usb, USB, 0x12, 0);
>
> +static APMU_CLK_OPS(sdh1, SDH0, 0x12, 48000000, &sdh_clk_ops);
> +static APMU_CLK_OPS(sdh2, SDH1, 0x12, 48000000, &sdh_clk_ops);
> +static APMU_CLK_OPS(sdh3, PXA168_SDH2, 0x12, 48000000, &sdh_clk_ops);
> +static APMU_CLK_OPS(sdh4, PXA168_SDH3, 0x12, 48000000, &sdh_clk_ops);
> +
> ?/* device and clock bindings */
> ?static struct clk_lookup pxa168_clkregs[] = {
> ? ? ? ?INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
> @@ -108,6 +139,10 @@ static struct clk_lookup pxa168_clkregs[] = {
> ? ? ? ?INIT_CLKREG(&clk_keypad, "pxa27x-keypad", NULL),
> ? ? ? ?INIT_CLKREG(&clk_eth, "pxa168-eth", "MFUCLK"),
> ? ? ? ?INIT_CLKREG(&clk_usb, "pxa168-ehci", "PXA168-USBCLK"),
> + ? ? ? INIT_CLKREG(&clk_sdh1, NULL, "PXA-SDHCLK"),
> + ? ? ? INIT_CLKREG(&clk_sdh2, NULL, "PXA-SDHCLK"),
> + ? ? ? INIT_CLKREG(&clk_sdh3, NULL, "PXA-SDHCLK"),
> + ? ? ? INIT_CLKREG(&clk_sdh4, NULL, "PXA-SDHCLK"),
> ?};
>
> ?static int __init pxa168_init(void)
> @@ -173,6 +208,10 @@ PXA168_DEVICE(ssp5, "pxa168-ssp", 4, SSP5, 0xd4021000, 0x40, 60, 61);
> ?PXA168_DEVICE(fb, "pxa168-fb", -1, LCD, 0xd420b000, 0x1c8);
> ?PXA168_DEVICE(keypad, "pxa27x-keypad", -1, KEYPAD, 0xd4012000, 0x4c);
> ?PXA168_DEVICE(eth, "pxa168-eth", -1, MFU, 0xc0800000, 0x0fff);
> +PXA168_DEVICE(sdh1, "sdhci-pxav2", 0, SDH1, 0xd4280000, 0x100);
> +PXA168_DEVICE(sdh2, "sdhci-pxav2", 1, SDH1, 0xd4281000, 0x100);
> +PXA168_DEVICE(sdh3, "sdhci-pxav2", 2, SDH2, 0xd427e000, 0x100);
> +PXA168_DEVICE(sdh4, "sdhci-pxav2", 3, SDH2, 0xd427f000, 0x100);
>
> ?struct resource pxa168_usb_host_resources[] = {
> ? ? ? ?/* USB Host conroller register base */
> --
> 1.7.0.4
>
next prev parent reply other threads:[~2011-12-20 13:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 12:37 [PATCH 2/3] mmc: sdhci-pxa: Add SDHCI driver for PXA16x Tanmay Upadhyay
2011-11-10 20:09 ` Chris Ball
2011-11-21 4:23 ` [PATCH 1/4] mmc: sdhci-pxa: Trivial fix in Kconfig Tanmay Upadhyay
2011-11-21 4:26 ` [PATCH v3 2/4] ARM: pxa168: Add SDHCI support Tanmay Upadhyay
2011-12-01 18:05 ` Chris Ball
2011-12-15 23:15 ` Chris Ball
2011-12-19 4:45 ` Haojian Zhuang
2011-12-19 4:55 ` Tanmay Upadhyay
2011-12-19 5:02 ` Haojian Zhuang
2011-12-19 5:17 ` Tanmay Upadhyay
2011-12-19 5:24 ` Haojian Zhuang
2011-12-20 13:13 ` [PATCH v4 " Tanmay Upadhyay
2011-12-20 13:25 ` Haojian Zhuang [this message]
2011-12-20 13:38 ` Haojian Zhuang
2011-12-20 13:44 ` Tanmay Upadhyay
2011-12-20 13:44 ` Tanmay Upadhyay
2011-12-20 21:03 ` Russell King - ARM Linux
2011-12-21 1:48 ` Haojian Zhuang
2011-12-29 13:43 ` [PATCH " Tanmay Upadhyay
2011-12-30 0:36 ` Haojian Zhuang
2012-01-23 22:45 ` Tanmay Upadhyay
2011-12-19 5:24 ` [PATCH v3 " Philip Rakity
2011-12-19 5:30 ` Haojian Zhuang
2011-11-21 4:26 ` [PATCH v2 3/4] mmc: sdhci-pxa: Add SDHCI driver for PXA16x Tanmay Upadhyay
[not found] ` <CAMj5Bki3Ev8K63538-dNbyijUw1oNTLChADLd4=Ef-LeCkoacw@mail.gmail.com>
2011-11-25 18:53 ` Philip Rakity
2011-11-21 4:27 ` [PATCH v2 4/4] ARM: pxa168/gplugd: Add support for SD port 1 Tanmay Upadhyay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN1soZzzu56SiUa4z2NY0HdqieYTZvM0q-nq1QsnCBLkeD70mg@mail.gmail.com \
--to=haojian.zhuang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).