From patchwork Thu Oct 16 22:06:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5094631 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 921849F38C for ; Thu, 16 Oct 2014 22:06:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 86D5C201C7 for ; Thu, 16 Oct 2014 22:06:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4994200E6 for ; Thu, 16 Oct 2014 22:06:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XetBw-0005Px-Do; Thu, 16 Oct 2014 22:06:40 +0000 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XetBt-0005OB-Tf; Thu, 16 Oct 2014 22:06:38 +0000 Received: by mail-pd0-f176.google.com with SMTP id fp1so3975394pdb.35 for ; Thu, 16 Oct 2014 15:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=iEcNwWGq36anDX9KN3pzs0fcOXa3qruhhud5gr6QbEk=; b=GuIty09D72d6Ay7wOGEN2rrcbxZuO0CWTgJTRvaXXFo0C56gi5gzW1uK3P7S1kJQ3p eHZuGwdT0ciJ+n0TeTbx3zOLrtH8CU9oTQ0QLOSYJo+aYsPut9szyAxtB/OG6PR9Vjbz UgMpqCy+CJbhEvG3RrWg4CbOM+DkhcokfnrlLLpDlPpolhIEqXN8vlsGZyQnPstWuUjs RZUT3l1jVmFafVoVfQr/KXOqlQvyWAJKA+nmdxuTwJuwUDTXe2GcipHvyrQ2DgWF1+PD VRbSsjFeccqf8zb6zI/PBLK8tJgKuO2FeJMROkOUWkHfqUElZDbsGFVQQ7geo8bmHuwD oPhg== X-Received: by 10.68.135.161 with SMTP id pt1mr4417005pbb.10.1413497176077; Thu, 16 Oct 2014 15:06:16 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1301:cc11:4aee:ef14:11d5]) by mx.google.com with ESMTPSA id df1sm20640010pbb.2.2014.10.16.15.06.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Oct 2014 15:06:14 -0700 (PDT) Date: Thu, 16 Oct 2014 15:06:11 -0700 From: Dmitry Torokhov To: Caesar Wang Subject: Re: [PATCH v11 1/5] thermal: rockchip: add driver for thermal Message-ID: <20141016220611.GB30009@dtor-ws> References: <1413466301-25952-1-git-send-email-caesar.wang@rock-chips.com> <1413466301-25952-2-git-send-email-caesar.wang@rock-chips.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1413466301-25952-2-git-send-email-caesar.wang@rock-chips.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141016_150638_017686_67604F60 X-CRM114-Status: GOOD ( 22.45 ) X-Spam-Score: -0.8 (/) Cc: huangtao@rock-chips.com, devicetree@vger.kernel.org, dbasehore@chromium.org, heiko@sntech.de, linux-pm@vger.kernel.org, linux-doc@vger.kernel.org, dianders@chromium.org, linux-kernel@vger.kernel.org, edubezval@gmail.com, linux-rockchip@lists.infradead.org, vladimir_zapolskiy@mentor.com, cf@rock-chips.com, rui.zhang@intel.com, cjf@rock-chips.com, zhengsq@rock-chips.com, linux-arm-kernel@lists.infradead.org, zyf@rock-chips.com X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Caesar, On Thu, Oct 16, 2014 at 09:31:37PM +0800, Caesar Wang wrote: > + > +struct rockchip_tsadc_platform_data { > + unsigned long temp_passive; > + unsigned long hw_shut_temp; > + int reset_mode; > + > + void (*irq_handle)(void __iomem *reg); > + void (*initialize)(int reset_mode, int chn, void __iomem *reg, > + unsigned long hw_shut_temp); > + int (*control)(void __iomem *reg, bool on, int chn); > + int (*code_to_temp)(u32 code); > + u32 (*temp_to_code)(int temp); > + void (*set_alarm_temp)(int chn, void __iomem *reg, > + unsigned long alarm_temp); > +}; Any time I see platform data and pdata I think about board-specific parameters that come either from board initialization code, device tree or ACPI, rather than chipset specific data. Do you think we could rename rockchip_tsadc_platform_data to rockchip_tsadc_chip? If you agree please fold the patch below into your next revision. More to come... Thanks. diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index 4ecc649..6d7472b 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -44,8 +44,24 @@ enum sensor_id { SENSOR_ID_END, }; +struct rockchip_tsadc_chip { + unsigned long temp_passive; + unsigned long hw_shut_temp; + enum reset_mode reset_mode; + + void (*irq_handle)(void __iomem *reg); + void (*initialize)(enum reset_mode reset_mode, int chn, + void __iomem *reg, + unsigned long hw_shut_temp); + int (*control)(void __iomem *reg, bool on, int chn); + int (*code_to_temp)(u32 code); + u32 (*temp_to_code)(int temp); + void (*set_alarm_temp)(int chn, void __iomem *reg, + unsigned long alarm_temp); +}; + struct rockchip_thermal_data { - const struct rockchip_tsadc_platform_data *pdata; + const struct rockchip_tsadc_chip *chip; struct thermal_zone_device *tz[SENSOR_ID_END]; struct thermal_cooling_device *cdev; void __iomem *regs; @@ -62,21 +78,6 @@ struct rockchip_thermal_data { struct clk *pclk; }; -struct rockchip_tsadc_platform_data { - unsigned long temp_passive; - unsigned long hw_shut_temp; - int reset_mode; - - void (*irq_handle)(void __iomem *reg); - void (*initialize)(int reset_mode, int chn, void __iomem *reg, - unsigned long hw_shut_temp); - int (*control)(void __iomem *reg, bool on, int chn); - int (*code_to_temp)(u32 code); - u32 (*temp_to_code)(int temp); - void (*set_alarm_temp)(int chn, void __iomem *reg, - unsigned long alarm_temp); -}; - /* TSADC V2 Sensor info define: */ #define TSADCV2_AUTO_CON 0x04 #define TSADCV2_INT_EN 0x08 @@ -234,7 +235,8 @@ static bool rk_tsadcv2_get_tshut_polarity_high(void __iomem *regs) * the channel, and you can set TSHUT output to gpio to reset the whole chip, * and you can set TSHUT output to cru to reset the whole chip. */ -static void rk_tsadcv2_initialize(int reset_mode, int chn, void __iomem *regs, +static void rk_tsadcv2_initialize(enum reset_mode reset_mode, int chn, + void __iomem *regs, unsigned long hw_shut_temp) { u32 shutdown_value; @@ -279,7 +281,7 @@ static void rk_tsadcv2_alarm_temp(int chn, void __iomem *regs, TSADCV2_COMP_INT(chn)); } -static const struct rockchip_tsadc_platform_data rk3288_tsadc_data = { +static const struct rockchip_tsadc_chip rk3288_tsadc_data = { .reset_mode = GPIO, /* default TSHUT via GPIO give PMIC */ .temp_passive = 80000, .hw_shut_temp = 120000, @@ -303,7 +305,7 @@ MODULE_DEVICE_TABLE(of, of_rockchip_thermal_match); static void rockchip_set_alarm_temp(struct rockchip_thermal_data *data, int alarm_temp, int chn) { - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; data->alarm_temp = alarm_temp; @@ -352,7 +354,7 @@ static void rockchip_thermal_initialize(struct rockchip_thermal_data *data) static void rockchip_thermal_control(struct rockchip_thermal_data *data, bool on, int chn) { - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; if (tsadc->control) tsadc->control(data->regs, on, chn); @@ -372,7 +374,7 @@ static void rockchip_thermal_control(struct rockchip_thermal_data *data, static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev) { struct rockchip_thermal_data *data = dev; - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; int chn; tsadc->irq_handle(data->regs); @@ -386,7 +388,7 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev) static int rockchip_thermal_set_trips(void *zone, long low, long high) { struct rockchip_thermal_data *data = zone; - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; low = clamp_val(low, LONG_MIN, LONG_MAX); high = clamp_val(high, LONG_MIN, LONG_MAX); @@ -407,7 +409,7 @@ static int rockchip_thermal_set_trips(void *zone, long low, long high) static int rockchip_thermal_get_cpu_temp(void *zone, long *out_temp) { struct rockchip_thermal_data *data = zone; - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; u32 val; /* the A/D value of the channel last conversion need some time */ @@ -423,7 +425,7 @@ static int rockchip_thermal_get_cpu_temp(void *zone, long *out_temp) static int rockchip_thermal_get_gpu_temp(void *zone, long *out_temp) { struct rockchip_thermal_data *data = zone; - const struct rockchip_tsadc_platform_data *tsadc = data->pdata; + const struct rockchip_tsadc_chip *tsadc = data->chip; u32 val; /* the A/D value of the channel last conversion need some time */ @@ -444,19 +446,19 @@ static int rockchip_configure_from_dt(struct device *dev, if (of_property_read_u32(np, "hw-shut-temp", &shut_temp)) { dev_warn(dev, "Missing default shutdown temp property\n"); - data->hw_shut_temp = data->pdata->hw_shut_temp; + data->hw_shut_temp = data->chip->hw_shut_temp; } else { data->hw_shut_temp = shut_temp; } if (of_property_read_u32(np, "tsadc-ht-reset-mode", &reset_mode)) { dev_warn(dev, "Missing default reset mode property\n"); - data->reset_mode = data->pdata->reset_mode; + data->reset_mode = data->chip->reset_mode; } else { data->reset_mode = reset_mode; } - data->temp_passive = data->pdata->temp_passive; + data->temp_passive = data->chip->temp_passive; return 0; } @@ -464,7 +466,7 @@ static int rockchip_configure_from_dt(struct device *dev, static int rockchip_thermal_probe(struct platform_device *pdev) { struct rockchip_thermal_data *data; - const struct rockchip_tsadc_platform_data *tsadc; + const struct rockchip_tsadc_chip *tsadc; const struct of_device_id *match; struct cpumask clip_cpus; @@ -489,10 +491,12 @@ static int rockchip_thermal_probe(struct platform_device *pdev) match = of_match_node(of_rockchip_thermal_match, np); if (!match) return -ENXIO; - data->pdata = (const struct rockchip_tsadc_platform_data *)match->data; - if (!data->pdata) + + tsadc = (const struct rockchip_tsadc_chip *)match->data; + if (!tsadc) return -EINVAL; - tsadc = data->pdata; + + data->chip = tsadc; data->clk = devm_clk_get(&pdev->dev, "tsadc"); if (IS_ERR(data->clk)) {