From patchwork Tue Aug 31 10:32:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 177632 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Tue, 31 Aug 2010 11:32:31 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1OqO8k-00084h-1i for chris@printf.net; Tue, 31 Aug 2010 11:32:30 +0100 Received: by mail.laptop.org (Postfix) id 0833B2437E; Tue, 31 Aug 2010 06:32:11 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id CAFD22437C for ; Tue, 31 Aug 2010 06:32:10 -0400 (EDT) X-ASG-Debug-ID: 1283250748-0b747c680001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id hPfmDud14PCvDdrW for ; Tue, 31 Aug 2010 06:32:28 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756658Ab0HaKc1 (ORCPT ); Tue, 31 Aug 2010 06:32:27 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:58243 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756177Ab0HaKc1 (ORCPT ); Tue, 31 Aug 2010 06:32:27 -0400 Received: from epmmp2 (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Sun Java(tm) System Messaging Server 7u3-15.01 64bit (built Feb 12 2010)) with ESMTP id <0L8000M4NIM15CE0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Tue, 31 Aug 2010 19:32:25 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0L8000CPFIM16U@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Tue, 31 Aug 2010 19:32:25 +0900 (KST) Received: from [127.0.0.1] ([10.89.53.131]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.4675); Tue, 31 Aug 2010 19:32:25 +0900 Date: Tue, 31 Aug 2010 19:32:25 +0900 From: Jaehoon Chung X-ASG-Orig-Subj: [PATCH] sdhci-s3c: support non-standard clock setting for c210 Subject: [PATCH] sdhci-s3c: support non-standard clock setting for c210 To: linux-mmc@vger.kernel.org, Kyungmin Park , matt@console-pimps.org, Marek Szyprowski , Kukjin Kim , Andrew Morton , Ben Dooks Message-id: <4C7CDA39.1020907@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=EUC-KR Content-transfer-encoding: 7BIT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ko; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1 X-OriginalArrivalTime: 31 Aug 2010 10:32:25.0584 (UTC) FILETIME=[CDBA1F00:01CB48F7] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1283250748 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.39506 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h index 30844c2..7c75ee3 100644 --- a/arch/arm/plat-samsung/include/plat/sdhci.h +++ b/arch/arm/plat-samsung/include/plat/sdhci.h @@ -15,6 +15,8 @@ #ifndef __PLAT_S3C_SDHCI_H #define __PLAT_S3C_SDHCI_H __FILE__ +#include + struct platform_device; struct mmc_host; struct mmc_card; @@ -288,4 +290,21 @@ static inline void s5pv210_default_sdhci3(void) { } #endif /* CONFIG_S5PV210_SETUP_SDHCI */ +/* re-define device name depending on support. */ +static inline void s3c_hsmmc_setname(char *name) +{ +#ifdef CONFIG_S3C_DEV_HSMMC + s3c_device_hsmmc0.name = name; +#endif +#ifdef CONFIG_S3C_DEV_HSMMC1 + s3c_device_hsmmc1.name = name; +#endif +#ifdef CONFIG_S3C_DEV_HSMMC2 + s3c_device_hsmmc2.name = name; +#endif +#ifdef CONFIG_S3C_DEV_HSMMC3 + s3c_device_hsmmc3.name = name; +#endif +} + #endif /* __PLAT_S3C_SDHCI_H */ diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 71ad416..3927793 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -52,6 +52,11 @@ struct sdhci_s3c { struct clk *clk_bus[MAX_BUS_CLK]; }; +enum soc_type { + TYPE_SAMSUNG, /* S5PC1XX, S3C... */ + TYPE_S5PC210, /* S5PC210 */ +}; + static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host) { return sdhci_priv(host); @@ -232,6 +237,52 @@ static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host) return min; } +/** +* sdhci_s3c_get_max_clk - callback to get maximum clock frequency. +*/ +static unsigned int sdhci_s5pc210_get_max_clock(struct sdhci_host *host) +{ + struct sdhci_s3c *ourhost = to_s3c(host); + unsigned int rate; + int ptr = ourhost->cur_clk; + + rate = clk_round_rate(ourhost->clk_bus[ptr], UINT_MAX); + + return rate; +} + +/** + * sdhci_s3c_get_min_clock - callback to get minimal supported clock value +*/ +static unsigned int sdhci_s5pc210_get_min_clock(struct sdhci_host *host) +{ + struct sdhci_s3c *ourhost = to_s3c(host); + unsigned int rate; + int ptr = ourhost->cur_clk; + + rate = clk_round_rate(ourhost->clk_bus[ptr], 400000); + + return rate; +} + +/** + * sdhci_s5pc210_set_clock - callback on clock change +*/ +static void sdhci_s5pc210_set_clock(struct sdhci_host *host, + unsigned int clock) +{ + struct sdhci_s3c *ourhost = to_s3c(host); + + if (clock == 0) + return; + + sdhci_s3c_set_clock(host, clock); + + clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock); + + host->clock = clock; +} + static struct sdhci_ops sdhci_s3c_ops = { .get_max_clock = sdhci_s3c_get_max_clk, .set_clock = sdhci_s3c_set_clock, @@ -395,6 +446,12 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) host->quirks = 0; host->irq = irq; + if (pdev->id_entry->driver_data == TYPE_S5PC210) { + sdhci_s3c_ops.set_clock = sdhci_s5pc210_set_clock; + sdhci_s3c_ops.get_min_clock = sdhci_s5pc210_get_min_clock; + sdhci_s3c_ops.get_max_clock = sdhci_s5pc210_get_max_clock; + } + /* Setup quirks for the controller */ host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; @@ -520,6 +577,16 @@ static int sdhci_s3c_resume(struct platform_device *dev) #define sdhci_s3c_resume NULL #endif +static struct platform_device_id sdhci_driver_ids[] = { + { + .name = "s3c-sdhci", + .driver_data = TYPE_SAMSUNG, + }, { + .name = "s5pc210-sdhci", + .driver_data = TYPE_S5PC210, + }, { }, +}; + static struct platform_driver sdhci_s3c_driver = { .probe = sdhci_s3c_probe, .remove = __devexit_p(sdhci_s3c_remove), @@ -529,6 +596,7 @@ static struct platform_driver sdhci_s3c_driver = { .owner = THIS_MODULE, .name = "s3c-sdhci", }, + .id_table = sdhci_driver_ids, }; static int __init sdhci_s3c_init(void)