From patchwork Fri Dec 30 06:30:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 709656 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3tqc832sqNz9ssP for ; Fri, 30 Dec 2016 17:32:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3530B398E; Fri, 30 Dec 2016 07:31:24 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s6WjOBsjNzaT; Fri, 30 Dec 2016 07:31:24 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A8C5A7607; Fri, 30 Dec 2016 07:30:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C07E6A75F5 for ; Fri, 30 Dec 2016 07:30:36 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vf12cONAIl9u for ; Fri, 30 Dec 2016 07:30:36 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTPS id AAEC2A75F1 for ; Fri, 30 Dec 2016 07:30:34 +0100 (CET) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OIZ02LA6JERFYA0@mailout4.samsung.com> for u-boot@lists.denx.de; Fri, 30 Dec 2016 15:30:27 +0900 (KST) Received: from epsmges5p2.samsung.com (unknown [182.195.40.67]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20161230063026epcas1p467b0fea72a1b506bbe7971365308cfeb~U9OGOnaW10956209562epcas1p4S; Fri, 30 Dec 2016 06:30:26 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2.samsung.com (EPCPMTA) with SMTP id A9.81.29876.20FF5685; Fri, 30 Dec 2016 15:30:26 +0900 (KST) Received: from epcpsbgm2new.samsung.com (u27.gpu120.samsung.co.kr [203.254.230.27]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20161230063025epcas5p4852c930a17f5e5f848fb3cb5c9164874~U9OFHvPFq0829808298epcas5p4O; Fri, 30 Dec 2016 06:30:25 +0000 (GMT) X-AuditID: b6c32a2d-f79a76d0000074b4-15-5865ff02ae59 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 96.FA.28332.10FF5685; Fri, 30 Dec 2016 15:30:25 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OIZ00728JEN3RC0@mmp2.samsung.com>; Fri, 30 Dec 2016 15:30:25 +0900 (KST) From: Jaehoon Chung To: u-boot@lists.denx.de Date: Fri, 30 Dec 2016 15:30:18 +0900 Message-id: <20161230063021.23756-9-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.2 In-reply-to: <20161230063021.23756-1-jh80.chung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsWy7bCmpi7T/9QIg+a7phY3frWxWrzd28nu wORx9s4ORo++LasYA5iiUm0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNT bZVcfAJ03TJzgOYrKZQ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07C07SBWbgI7E9m/HmUBsEQEJiV/9V8G6mQW0JKbs vMMGYgsL+Eg83bgXrIZFQFXiwrVdYDavgLVE183PbBDb5CUWnj8CFucUsJFoOjUVKM4BtMxa 4tL17AmMvAsYGVYxSqQWJBcUJ6XnGuWllusVJ+YWl+al6yXn525iBAfhM+kdjId3uR9iFOBg VOLh/VGWGiHEmlhWXJl7iFGCg1lJhDfrL1CINyWxsiq1KD++qDQntfgQoynQXROZpUST84ER klcSb2hibmJubGBhbmlpYqQkzts4+1m4kEB6YklqdmpqQWoRTB8TB6dUAyOn/7YXIfLfFjPn 3jPdt6r685EJbocKzy1lWuy2TuB3fcAd08YrV+59fMj3Ne9BpbeE0IO7DXfU165q1fmcxKHE 7f1h7wymLMF9KUHqfcYbONNLzJYrz84/NOdgWNK7ffvmOsysDVxVNblLys6pnTNLQf7YtXUb Tyivnf74pvM2TZ6tGn7zjF8osRRnJBpqMRcVJwIAM2z5TFgCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161230063025epcas5p4852c930a17f5e5f848fb3cb5c9164874 X-Msg-Generator: CA X-Sender-IP: 203.254.230.27 X-Local-Sender: =?UTF-8?B?7KCV7J6s7ZuIG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbUzUo7LGF7J6EKS/ssYXsnoQ=?= X-Global-Sender: =?UTF-8?B?SmFlaG9vbiBDaHVuZxtUaXplbiBQbGF0Zm9ybSBMYWIuG1Nh?= =?UTF-8?B?bXN1bmcgRWxlY3Ryb25pY3MbUzUvU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1NUQUYbQzEwVjgxMTE=?= CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20161230063025epcas5p4852c930a17f5e5f848fb3cb5c9164874 X-RootMTR: 20161230063025epcas5p4852c930a17f5e5f848fb3cb5c9164874 References: <20161230063021.23756-1-jh80.chung@samsung.com> Subject: [U-Boot] [PATCH 08/11] mmc: sdhci: move the callback function into sdhci_ops X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" callback function should be moved into sdhci_ops struct. Other controller can use these ops for controlling clock or their own specific register. Signed-off-by: Jaehoon Chung --- drivers/mmc/s5p_sdhci.c | 9 ++++++--- drivers/mmc/sdhci.c | 8 ++++---- include/sdhci.h | 18 +++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c index 2a4cdc0..1f1d2ed 100644 --- a/drivers/mmc/s5p_sdhci.c +++ b/drivers/mmc/s5p_sdhci.c @@ -79,6 +79,11 @@ static void s5p_set_clock(struct sdhci_host *host, u32 div) set_mmc_clk(host->index, div); } +static const struct sdhci_ops s5p_sdhci_ops = { + .set_clock = &s5p_set_clock, + .set_control_reg = &s5p_sdhci_set_control_reg, +}; + static int s5p_sdhci_core_init(struct sdhci_host *host) { host->name = S5P_NAME; @@ -87,9 +92,7 @@ static int s5p_sdhci_core_init(struct sdhci_host *host) SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; - - host->set_control_reg = &s5p_sdhci_set_control_reg; - host->set_clock = &s5p_set_clock; + host->ops = &s5p_sdhci_ops; if (host->bus_width == 8) host->host_caps |= MMC_MODE_8BIT; diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 9125e5d..6ce5e8f 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -359,8 +359,8 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) div >>= 1; } - if (host->set_clock) - host->set_clock(host->index, div); + if (host->ops->set_clock) + host->ops->set_clock(host, div); clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN) @@ -430,8 +430,8 @@ static int sdhci_set_ios(struct mmc *mmc) u32 ctrl; struct sdhci_host *host = mmc->priv; - if (host->set_control_reg) - host->set_control_reg(host); + if (host->ops->set_control_reg) + host->ops->set_control_reg(host); if (mmc->clock != host->clock) sdhci_set_clock(mmc, mmc->clock); diff --git a/include/sdhci.h b/include/sdhci.h index e4299d1..abe4846 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -227,14 +227,16 @@ struct sdhci_host; #define SDHCI_DEFAULT_BOUNDARY_ARG (7) struct sdhci_ops { #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS - u32 (*read_l)(struct sdhci_host *host, int reg); - u16 (*read_w)(struct sdhci_host *host, int reg); - u8 (*read_b)(struct sdhci_host *host, int reg); - void (*write_l)(struct sdhci_host *host, u32 val, int reg); - void (*write_w)(struct sdhci_host *host, u16 val, int reg); - void (*write_b)(struct sdhci_host *host, u8 val, int reg); + u32 (*read_l)(struct sdhci_host *host, int reg); + u16 (*read_w)(struct sdhci_host *host, int reg); + u8 (*read_b)(struct sdhci_host *host, int reg); + void (*write_l)(struct sdhci_host *host, u32 val, int reg); + void (*write_w)(struct sdhci_host *host, u16 val, int reg); + void (*write_b)(struct sdhci_host *host, u8 val, int reg); #endif - int (*get_cd)(struct sdhci_host *host); + int (*get_cd)(struct sdhci_host *host); + void (*set_control_reg)(struct sdhci_host *host); + void (*set_clock)(struct sdhci_host *host, u32 div); }; struct sdhci_host { @@ -253,8 +255,6 @@ struct sdhci_host { struct gpio_desc pwr_gpio; /* Power GPIO */ struct gpio_desc cd_gpio; /* Card Detect GPIO */ - void (*set_control_reg)(struct sdhci_host *host); - void (*set_clock)(int dev_index, unsigned int div); uint voltages; struct mmc_config cfg;