* [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
From: Andrew Jeffery @ 2019-09-04 0:02 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <CAPDyKFpWJu3RH4TWoO_wcJq0LDrM_fAUfsCC==e8O_6A8dLhiA@mail.gmail.com>
On Wed, 4 Sep 2019, at 00:18, Ulf Hansson wrote:
> On Mon, 2 Sep 2019 at 07:26, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> >
> >
> > On Mon, 2 Sep 2019, at 13:42, Joel Stanley wrote:
> > > On Mon, 2 Sep 2019 at 03:58, Andrew Jeffery <andrew@aj.id.au> wrote:
> > > >
> > > > Resolves the following build error reported by the 0-day bot:
> > > >
> > > > ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
> > > >
> > > > SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the
> > > > callsite to maintain build coverage for the rest of the driver.
> > > >
> > > > Reported-by: kbuild test robot <lkp@intel.com>
> > > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > > > ---
> > > > drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++----------
> > > > 1 file changed, 25 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
> > > > index d5acb5afc50f..96ca494752c5 100644
> > > > --- a/drivers/mmc/host/sdhci-of-aspeed.c
> > > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c
> > > > @@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = {
> > > > .remove = aspeed_sdhci_remove,
> > > > };
> > > >
> > > > -static int aspeed_sdc_probe(struct platform_device *pdev)
> > > > -
> > > > +static int aspeed_sdc_create_sdhcis(struct platform_device *pdev)
> > > > {
> > > > +#if defined(CONFIG_OF_ADDRESS)
> > >
> > > This is going to be untested code forever, as no one will be running
> > > on a chip with this hardware present but OF_ADDRESS disabled.
> > >
> > > How about we make the driver depend on OF_ADDRESS instead?
> >
> > Testing is split into two pieces here: compile-time and run-time.
> > Clearly the run-time behaviour is going to be broken on configurations
> > without CONFIG_OF_ADDRESS (SPARC as mentioned), but I don't think
> > that means we shouldn't allow it to be compiled in that case
> > (e.g. CONFIG_COMPILE_TEST performs a similar role).
> >
> > With respect to compile-time it's possible to compile either path as
> > demonstrated by the build failure report.
> >
> > Having said that there's no reason we couldn't do what you suggest,
> > just it wasn't the existing solution pattern for the problem (there are
> > several other drivers that suffered the same bug that were fixed in the
> > style of this patch). Either way works, it's all somewhat academic.
> > Your suggestion is more obvious in terms of correctness, but this
> > patch is basically just code motion (the only addition is the `#if`/
> > `#endif` lines over what was already there if we disregard the
> > function declaration/invocation). I'll change it if there are further
> > complaints and a reason to do a v3.
>
> I am in favor of Joel's suggestion as I don't really like having
> ifdefs bloating around in the driver (unless very good reasons).
> Please re-spin a v3.
>
> Another option is to implement stub function and to deal with error
> codes, but that sounds more like a long term thingy, if even
> applicable here.
No worries then, will post a respin shortly.
Andrew
^ permalink raw reply
* [GIT PULL] ARM: aspeed: defconfig changes for 5.4
From: Arnd Bergmann @ 2019-09-03 16:59 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <CACPK8XdyWzghA0QPDzA_MK5FYwhT5afqDJHNdhc8mfD2uk8MfQ@mail.gmail.com>
On Sun, Aug 25, 2019 at 4:10 PM Joel Stanley <joel@jms.id.au> wrote:
> ----------------------------------------------------------------
> ASPEED defconfig updates for 5.4
>
> - Enable the new AST2600 in multi_v7 and the aspeed_g5 configs.
>
> - Regenerate defconfigs to drop old options
>
> - Clean up network options
Pulled into arm/defconfig, thanks!
Arnd
^ permalink raw reply
* [PATCH v2 0/4] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support
From: Ulf Hansson @ 2019-09-03 15:10 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-1-andrew@aj.id.au>
On Mon, 2 Sep 2019 at 05:58, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> Hello,
>
> I've added a couple of patches since v1 of this series. The horizon has
> broadened slightly with a fix for SPARC builds as well in patch 1/4. Ulf
> suggested a minor cleanup on v1 with respect to handling of the current clock
> value, so that's now patch 2/4. Patches 3/4 and 4/4 are as they were in v1.
Applied patch 2->4 for next, thanks!
Kind regards
Uffe
>
> The v1 series can be found here:
>
> https://patchwork.ozlabs.org/cover/1155757/
>
> Please review!
>
> Andrew
>
> Andrew Jeffery (4):
> mmc: sdhci-of-aspeed: Fix link failure for SPARC
> mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
> mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
> mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
>
> drivers/mmc/host/sdhci-of-aspeed.c | 62 ++++++++++++++++++++----------
> 1 file changed, 42 insertions(+), 20 deletions(-)
>
> --
> 2.20.1
>
^ permalink raw reply
* [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
From: Ulf Hansson @ 2019-09-03 14:48 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <83570e25-b20a-4a17-85ea-15a9a53289bf@www.fastmail.com>
On Mon, 2 Sep 2019 at 07:26, Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Mon, 2 Sep 2019, at 13:42, Joel Stanley wrote:
> > On Mon, 2 Sep 2019 at 03:58, Andrew Jeffery <andrew@aj.id.au> wrote:
> > >
> > > Resolves the following build error reported by the 0-day bot:
> > >
> > > ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
> > >
> > > SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the
> > > callsite to maintain build coverage for the rest of the driver.
> > >
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > > ---
> > > drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++----------
> > > 1 file changed, 25 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
> > > index d5acb5afc50f..96ca494752c5 100644
> > > --- a/drivers/mmc/host/sdhci-of-aspeed.c
> > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c
> > > @@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = {
> > > .remove = aspeed_sdhci_remove,
> > > };
> > >
> > > -static int aspeed_sdc_probe(struct platform_device *pdev)
> > > -
> > > +static int aspeed_sdc_create_sdhcis(struct platform_device *pdev)
> > > {
> > > +#if defined(CONFIG_OF_ADDRESS)
> >
> > This is going to be untested code forever, as no one will be running
> > on a chip with this hardware present but OF_ADDRESS disabled.
> >
> > How about we make the driver depend on OF_ADDRESS instead?
>
> Testing is split into two pieces here: compile-time and run-time.
> Clearly the run-time behaviour is going to be broken on configurations
> without CONFIG_OF_ADDRESS (SPARC as mentioned), but I don't think
> that means we shouldn't allow it to be compiled in that case
> (e.g. CONFIG_COMPILE_TEST performs a similar role).
>
> With respect to compile-time it's possible to compile either path as
> demonstrated by the build failure report.
>
> Having said that there's no reason we couldn't do what you suggest,
> just it wasn't the existing solution pattern for the problem (there are
> several other drivers that suffered the same bug that were fixed in the
> style of this patch). Either way works, it's all somewhat academic.
> Your suggestion is more obvious in terms of correctness, but this
> patch is basically just code motion (the only addition is the `#if`/
> `#endif` lines over what was already there if we disregard the
> function declaration/invocation). I'll change it if there are further
> complaints and a reason to do a v3.
I am in favor of Joel's suggestion as I don't really like having
ifdefs bloating around in the driver (unless very good reasons).
Please re-spin a v3.
Another option is to implement stub function and to deal with error
codes, but that sounds more like a long term thingy, if even
applicable here.
Kind regards
Uffe
^ permalink raw reply
* [GIT PULL] ARM: aspeed: devicetree changes for 5.4
From: Arnd Bergmann @ 2019-09-03 14:03 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <CACPK8XfKHpNYXNE_VRaLeGUQa7-hkmUS0nsPfaeSLE4sckKFHg@mail.gmail.com>
On Sun, Aug 25, 2019 at 4:10 PM Joel Stanley <joel@jms.id.au> wrote:
> ----------------------------------------------------------------
> ASPEED device tree updates for 5.4
>
> New machines:
>
> - Facebook Wedge100, Wedge40 and Minipack
> - Lenovo Hr855xg2
> - Wistron Mihawk
>
> There's a few other updates, notably some changes to to use the newly
> added SDHCI driver.
Pulled into arm/dt, thanks!
Arnd
^ permalink raw reply
* [GIT PULL] ARM: aspeed: arch changes for 5.4
From: Arnd Bergmann @ 2019-09-03 12:19 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <CACPK8Xc1aSp5fXL3cEzC9SJsCXG2JwsSPpQrW3a09dkvhCyHHA@mail.gmail.com>
On Sun, Aug 25, 2019 at 4:10 PM Joel Stanley <joel@jms.id.au> wrote:
>
> Hello ARM Maintainers,
>
> Here's my first mach-aspeed pull request. We finally had to add some
> code here to support SMP on the shiny new ASPEED AST2600.
>
> The following changes since commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b:
>
> Linus 5.3-rc1 (2019-07-21 14:05:38 -0700)
>
> are available in the Git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/joel/aspeed.git \
> tags/aspeed-5.4-arch
>
Pulled into arm/soc branch, after changing Olof's patchwork wrapper script
to ignore the '\' character at the line break.
Thanks
Arnd
^ permalink raw reply
* [PATCH v2 1/3] dt-bindings: hwmon: Document ibm, cffps2 compatible string
From: Rob Herring @ 2019-09-02 13:39 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-2-git-send-email-eajames@linux.ibm.com>
On Fri, 30 Aug 2019 14:11:01 -0500, Eddie James wrote:
> Document the compatible string for version 2 of the IBM CFFPS PSU.
>
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
> Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* [PATCH 3/3] pmbus: ibm-cffps: Add support for version 2 of the PSU
From: kbuild test robot @ 2019-09-02 7:49 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567181385-22129-4-git-send-email-eajames@linux.ibm.com>
Hi Eddie,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Eddie-James/pmbus-ibm-cffps-Add-support-for-version-2-of-PSU/20190901-151755
config: x86_64-randconfig-s0-09021304 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-11) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/hwmon/pmbus/ibm-cffps.c: In function 'ibm_cffps_probe':
>> drivers/hwmon/pmbus/ibm-cffps.c:404:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
vs = (int)md;
^
vim +404 drivers/hwmon/pmbus/ibm-cffps.c
393
394 static int ibm_cffps_probe(struct i2c_client *client,
395 const struct i2c_device_id *id)
396 {
397 int i, rc, vs;
398 struct dentry *debugfs;
399 struct dentry *ibm_cffps_dir;
400 struct ibm_cffps *psu;
401 const void *md = of_device_get_match_data(&client->dev);
402
403 if (md)
> 404 vs = (int)md;
405 else if (id)
406 vs = (int)id->driver_data;
407 else
408 vs = 1;
409
410 client->dev.platform_data = &ibm_cffps_pdata;
411 rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs - 1]);
412 if (rc)
413 return rc;
414
415 /*
416 * Don't fail the probe if there isn't enough memory for leds and
417 * debugfs.
418 */
419 psu = devm_kzalloc(&client->dev, sizeof(*psu), GFP_KERNEL);
420 if (!psu)
421 return 0;
422
423 psu->version = vs;
424 psu->client = client;
425 mutex_init(&psu->input_history.update_lock);
426 psu->input_history.last_update = jiffies - HZ;
427
428 ibm_cffps_create_led_class(psu);
429
430 /* Don't fail the probe if we can't create debugfs */
431 debugfs = pmbus_get_debugfs_dir(client);
432 if (!debugfs)
433 return 0;
434
435 ibm_cffps_dir = debugfs_create_dir(client->name, debugfs);
436 if (!ibm_cffps_dir)
437 return 0;
438
439 for (i = 0; i < CFFPS_DEBUGFS_NUM_ENTRIES; ++i)
440 psu->debugfs_entries[i] = i;
441
442 debugfs_create_file("input_history", 0444, ibm_cffps_dir,
443 &psu->debugfs_entries[CFFPS_DEBUGFS_INPUT_HISTORY],
444 &ibm_cffps_fops);
445 debugfs_create_file("fru", 0444, ibm_cffps_dir,
446 &psu->debugfs_entries[CFFPS_DEBUGFS_FRU],
447 &ibm_cffps_fops);
448 debugfs_create_file("part_number", 0444, ibm_cffps_dir,
449 &psu->debugfs_entries[CFFPS_DEBUGFS_PN],
450 &ibm_cffps_fops);
451 debugfs_create_file("serial_number", 0444, ibm_cffps_dir,
452 &psu->debugfs_entries[CFFPS_DEBUGFS_SN],
453 &ibm_cffps_fops);
454 debugfs_create_file("ccin", 0444, ibm_cffps_dir,
455 &psu->debugfs_entries[CFFPS_DEBUGFS_CCIN],
456 &ibm_cffps_fops);
457 debugfs_create_file("fw_version", 0444, ibm_cffps_dir,
458 &psu->debugfs_entries[CFFPS_DEBUGFS_FW],
459 &ibm_cffps_fops);
460
461 return 0;
462 }
463
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 30810 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20190902/23d9fa8f/attachment-0001.gz>
^ permalink raw reply
* [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
From: Andrew Jeffery @ 2019-09-02 5:26 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <CACPK8XfYgEUfaK6rtr+FdEq-Vau6d4wE2Rvfp6Q4G2-kjVLT0g@mail.gmail.com>
On Mon, 2 Sep 2019, at 13:42, Joel Stanley wrote:
> On Mon, 2 Sep 2019 at 03:58, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> > Resolves the following build error reported by the 0-day bot:
> >
> > ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
> >
> > SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the
> > callsite to maintain build coverage for the rest of the driver.
> >
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > ---
> > drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++----------
> > 1 file changed, 25 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
> > index d5acb5afc50f..96ca494752c5 100644
> > --- a/drivers/mmc/host/sdhci-of-aspeed.c
> > +++ b/drivers/mmc/host/sdhci-of-aspeed.c
> > @@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = {
> > .remove = aspeed_sdhci_remove,
> > };
> >
> > -static int aspeed_sdc_probe(struct platform_device *pdev)
> > -
> > +static int aspeed_sdc_create_sdhcis(struct platform_device *pdev)
> > {
> > +#if defined(CONFIG_OF_ADDRESS)
>
> This is going to be untested code forever, as no one will be running
> on a chip with this hardware present but OF_ADDRESS disabled.
>
> How about we make the driver depend on OF_ADDRESS instead?
Testing is split into two pieces here: compile-time and run-time.
Clearly the run-time behaviour is going to be broken on configurations
without CONFIG_OF_ADDRESS (SPARC as mentioned), but I don't think
that means we shouldn't allow it to be compiled in that case
(e.g. CONFIG_COMPILE_TEST performs a similar role).
With respect to compile-time it's possible to compile either path as
demonstrated by the build failure report.
Having said that there's no reason we couldn't do what you suggest,
just it wasn't the existing solution pattern for the problem (there are
several other drivers that suffered the same bug that were fixed in the
style of this patch). Either way works, it's all somewhat academic.
Your suggestion is more obvious in terms of correctness, but this
patch is basically just code motion (the only addition is the `#if`/
`#endif` lines over what was already there if we disregard the
function declaration/invocation). I'll change it if there are further
complaints and a reason to do a v3.
Andrew
^ permalink raw reply
* [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
From: Joel Stanley @ 2019-09-02 4:12 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-2-andrew@aj.id.au>
On Mon, 2 Sep 2019 at 03:58, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> Resolves the following build error reported by the 0-day bot:
>
> ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
>
> SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the
> callsite to maintain build coverage for the rest of the driver.
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++----------
> 1 file changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
> index d5acb5afc50f..96ca494752c5 100644
> --- a/drivers/mmc/host/sdhci-of-aspeed.c
> +++ b/drivers/mmc/host/sdhci-of-aspeed.c
> @@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = {
> .remove = aspeed_sdhci_remove,
> };
>
> -static int aspeed_sdc_probe(struct platform_device *pdev)
> -
> +static int aspeed_sdc_create_sdhcis(struct platform_device *pdev)
> {
> +#if defined(CONFIG_OF_ADDRESS)
This is going to be untested code forever, as no one will be running
on a chip with this hardware present but OF_ADDRESS disabled.
How about we make the driver depend on OF_ADDRESS instead?
Cheers,
Joel
> struct device_node *parent, *child;
> +
> + parent = pdev->dev.of_node;
> +
> + for_each_available_child_of_node(parent, child) {
> + struct platform_device *cpdev;
> +
> + cpdev = of_platform_device_create(child, NULL, &pdev->dev);
> + if (!cpdev) {
> + of_node_put(child);
> + return -ENODEV;
> + }
> + }
> +#endif
> +
> + return 0;
> +}
> +
> +static int aspeed_sdc_probe(struct platform_device *pdev)
> +
> +{
> struct aspeed_sdc *sdc;
> int ret;
>
> @@ -256,17 +276,9 @@ static int aspeed_sdc_probe(struct platform_device *pdev)
>
> dev_set_drvdata(&pdev->dev, sdc);
>
> - parent = pdev->dev.of_node;
> - for_each_available_child_of_node(parent, child) {
> - struct platform_device *cpdev;
> -
> - cpdev = of_platform_device_create(child, NULL, &pdev->dev);
> - if (!cpdev) {
> - of_node_put(child);
> - ret = -ENODEV;
> - goto err_clk;
> - }
> - }
> + ret = aspeed_sdc_create_sdhcis(pdev);
> + if (ret)
> + goto err_clk;
>
> return 0;
>
> --
> 2.20.1
>
^ permalink raw reply
* [PATCH v2 4/4] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
From: Andrew Jeffery @ 2019-09-02 3:58 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-1-andrew@aj.id.au>
Add a get_max_clock() handler to sdhci-of-aspeed to report f_max as the
maximum clock rate if it is set. This enables artificial limitation of
the bus speed via max-frequency in the devicetree for e.g. the AST2600
evaluation board where I was seeing errors at 200MHz.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/mmc/host/sdhci-of-aspeed.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
index c31d74427c49..a8a5341b526c 100644
--- a/drivers/mmc/host/sdhci-of-aspeed.c
+++ b/drivers/mmc/host/sdhci-of-aspeed.c
@@ -52,16 +52,24 @@ static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,
static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
{
+ struct sdhci_pltfm_host *pltfm_host;
+ unsigned long parent;
int div;
u16 clk;
+ pltfm_host = sdhci_priv(host);
+ parent = clk_get_rate(pltfm_host->clk);
+
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
if (clock == 0)
return;
+ if (WARN_ON(clock > host->max_clk))
+ clock = host->max_clk;
+
for (div = 1; div < 256; div *= 2) {
- if ((host->max_clk / div) <= clock)
+ if ((parent / div) <= clock)
break;
}
div >>= 1;
@@ -71,6 +79,14 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
sdhci_enable_clk(host, clk);
}
+static unsigned int aspeed_sdhci_get_max_clock(struct sdhci_host *host)
+{
+ if (host->mmc->f_max)
+ return host->mmc->f_max;
+
+ return sdhci_pltfm_clk_get_max_clock(host);
+}
+
static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)
{
struct sdhci_pltfm_host *pltfm_priv;
@@ -97,7 +113,7 @@ static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)
static const struct sdhci_ops aspeed_sdhci_ops = {
.set_clock = aspeed_sdhci_set_clock,
- .get_max_clock = sdhci_pltfm_clk_get_max_clock,
+ .get_max_clock = aspeed_sdhci_get_max_clock,
.set_bus_width = aspeed_sdhci_set_bus_width,
.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
.reset = sdhci_reset,
--
2.20.1
^ permalink raw reply related
* [PATCH v2 3/4] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
From: Andrew Jeffery @ 2019-09-02 3:58 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-1-andrew@aj.id.au>
The early-exit didn't seem to matter on the AST2500, but on the AST2600
the SD clock genuinely may not be running on entry to
aspeed_sdhci_set_clock(). Remove the early exit to ensure we always run
sdhci_enable_clk().
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/mmc/host/sdhci-of-aspeed.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
index 213b3dbd49ef..c31d74427c49 100644
--- a/drivers/mmc/host/sdhci-of-aspeed.c
+++ b/drivers/mmc/host/sdhci-of-aspeed.c
@@ -55,9 +55,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
int div;
u16 clk;
- if (clock == host->clock)
- return;
-
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
if (clock == 0)
--
2.20.1
^ permalink raw reply related
* [PATCH v2 2/4] mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
From: Andrew Jeffery @ 2019-09-02 3:58 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-1-andrew@aj.id.au>
host->clock is already managed by sdhci_set_ios().
Suggested-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/mmc/host/sdhci-of-aspeed.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
index 96ca494752c5..213b3dbd49ef 100644
--- a/drivers/mmc/host/sdhci-of-aspeed.c
+++ b/drivers/mmc/host/sdhci-of-aspeed.c
@@ -61,7 +61,7 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
if (clock == 0)
- goto out;
+ return;
for (div = 1; div < 256; div *= 2) {
if ((host->max_clk / div) <= clock)
@@ -72,9 +72,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
clk = div << SDHCI_DIVIDER_SHIFT;
sdhci_enable_clk(host, clk);
-
-out:
- host->clock = clock;
}
static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)
--
2.20.1
^ permalink raw reply related
* [PATCH v2 1/4] mmc: sdhci-of-aspeed: Fix link failure for SPARC
From: Andrew Jeffery @ 2019-09-02 3:58 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190902035842.2747-1-andrew@aj.id.au>
Resolves the following build error reported by the 0-day bot:
ERROR: "of_platform_device_create" [drivers/mmc/host/sdhci-of-aspeed.ko] undefined!
SPARC does not set CONFIG_OF_ADDRESS so the symbol is missing. Guard the
callsite to maintain build coverage for the rest of the driver.
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/mmc/host/sdhci-of-aspeed.c | 38 ++++++++++++++++++++----------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
index d5acb5afc50f..96ca494752c5 100644
--- a/drivers/mmc/host/sdhci-of-aspeed.c
+++ b/drivers/mmc/host/sdhci-of-aspeed.c
@@ -224,10 +224,30 @@ static struct platform_driver aspeed_sdhci_driver = {
.remove = aspeed_sdhci_remove,
};
-static int aspeed_sdc_probe(struct platform_device *pdev)
-
+static int aspeed_sdc_create_sdhcis(struct platform_device *pdev)
{
+#if defined(CONFIG_OF_ADDRESS)
struct device_node *parent, *child;
+
+ parent = pdev->dev.of_node;
+
+ for_each_available_child_of_node(parent, child) {
+ struct platform_device *cpdev;
+
+ cpdev = of_platform_device_create(child, NULL, &pdev->dev);
+ if (!cpdev) {
+ of_node_put(child);
+ return -ENODEV;
+ }
+ }
+#endif
+
+ return 0;
+}
+
+static int aspeed_sdc_probe(struct platform_device *pdev)
+
+{
struct aspeed_sdc *sdc;
int ret;
@@ -256,17 +276,9 @@ static int aspeed_sdc_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, sdc);
- parent = pdev->dev.of_node;
- for_each_available_child_of_node(parent, child) {
- struct platform_device *cpdev;
-
- cpdev = of_platform_device_create(child, NULL, &pdev->dev);
- if (!cpdev) {
- of_node_put(child);
- ret = -ENODEV;
- goto err_clk;
- }
- }
+ ret = aspeed_sdc_create_sdhcis(pdev);
+ if (ret)
+ goto err_clk;
return 0;
--
2.20.1
^ permalink raw reply related
* [PATCH v2 0/4] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support
From: Andrew Jeffery @ 2019-09-02 3:58 UTC (permalink / raw)
To: linux-aspeed
Hello,
I've added a couple of patches since v1 of this series. The horizon has
broadened slightly with a fix for SPARC builds as well in patch 1/4. Ulf
suggested a minor cleanup on v1 with respect to handling of the current clock
value, so that's now patch 2/4. Patches 3/4 and 4/4 are as they were in v1.
The v1 series can be found here:
https://patchwork.ozlabs.org/cover/1155757/
Please review!
Andrew
Andrew Jeffery (4):
mmc: sdhci-of-aspeed: Fix link failure for SPARC
mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
drivers/mmc/host/sdhci-of-aspeed.c | 62 ++++++++++++++++++++----------
1 file changed, 42 insertions(+), 20 deletions(-)
--
2.20.1
^ permalink raw reply
* [PATCH v2 3/3] pmbus: ibm-cffps: Add support for version 2 of the PSU
From: Guenter Roeck @ 2019-08-31 15:28 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-4-git-send-email-eajames@linux.ibm.com>
On Fri, Aug 30, 2019 at 02:11:03PM -0500, Eddie James wrote:
> Version 2 of the PSU supports a second page of data and changes the
> format of the FW version. Use the devicetree binding to differentiate
> between the version the driver should use.
>
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
Applied to hwmon-next.
Thanks,
Guenter
> ---
> Changes since v1:
> - use an enum for the version instead of integers 1, 2, etc
>
> drivers/hwmon/pmbus/ibm-cffps.c | 110 ++++++++++++++++++++++++++++++++--------
> 1 file changed, 88 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
> index ee2ee9e..d44745e 100644
> --- a/drivers/hwmon/pmbus/ibm-cffps.c
> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
> @@ -12,6 +12,7 @@
> #include <linux/leds.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> +#include <linux/of_device.h>
> #include <linux/pmbus.h>
>
> #include "pmbus.h"
> @@ -20,8 +21,9 @@
> #define CFFPS_PN_CMD 0x9B
> #define CFFPS_SN_CMD 0x9E
> #define CFFPS_CCIN_CMD 0xBD
> -#define CFFPS_FW_CMD_START 0xFA
> -#define CFFPS_FW_NUM_BYTES 4
> +#define CFFPS_FW_CMD 0xFA
> +#define CFFPS1_FW_NUM_BYTES 4
> +#define CFFPS2_FW_NUM_WORDS 3
> #define CFFPS_SYS_CONFIG_CMD 0xDA
>
> #define CFFPS_INPUT_HISTORY_CMD 0xD6
> @@ -52,6 +54,8 @@ enum {
> CFFPS_DEBUGFS_NUM_ENTRIES
> };
>
> +enum versions { cffps1, cffps2 };
> +
> struct ibm_cffps_input_history {
> struct mutex update_lock;
> unsigned long last_update;
> @@ -61,6 +65,7 @@ struct ibm_cffps_input_history {
> };
>
> struct ibm_cffps {
> + enum versions version;
> struct i2c_client *client;
>
> struct ibm_cffps_input_history input_history;
> @@ -132,6 +137,8 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
> struct ibm_cffps *psu = to_psu(idxp, idx);
> char data[I2C_SMBUS_BLOCK_MAX] = { 0 };
>
> + pmbus_set_page(psu->client, 0);
> +
> switch (idx) {
> case CFFPS_DEBUGFS_INPUT_HISTORY:
> return ibm_cffps_read_input_history(psu, buf, count, ppos);
> @@ -152,16 +159,36 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
> rc = snprintf(data, 5, "%04X", rc);
> goto done;
> case CFFPS_DEBUGFS_FW:
> - for (i = 0; i < CFFPS_FW_NUM_BYTES; ++i) {
> - rc = i2c_smbus_read_byte_data(psu->client,
> - CFFPS_FW_CMD_START + i);
> - if (rc < 0)
> - return rc;
> + switch (psu->version) {
> + case cffps1:
> + for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) {
> + rc = i2c_smbus_read_byte_data(psu->client,
> + CFFPS_FW_CMD +
> + i);
> + if (rc < 0)
> + return rc;
> +
> + snprintf(&data[i * 2], 3, "%02X", rc);
> + }
>
> - snprintf(&data[i * 2], 3, "%02X", rc);
> - }
> + rc = i * 2;
> + break;
> + case cffps2:
> + for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) {
> + rc = i2c_smbus_read_word_data(psu->client,
> + CFFPS_FW_CMD +
> + i);
> + if (rc < 0)
> + return rc;
> +
> + snprintf(&data[i * 4], 5, "%04X", rc);
> + }
>
> - rc = i * 2;
> + rc = i * 4;
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> goto done;
> default:
> return -EINVAL;
> @@ -279,6 +306,8 @@ static void ibm_cffps_led_brightness_set(struct led_classdev *led_cdev,
> psu->led_state = CFFPS_LED_ON;
> }
>
> + pmbus_set_page(psu->client, 0);
> +
> rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
> psu->led_state);
> if (rc < 0)
> @@ -299,6 +328,8 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
> if (led_cdev->brightness == LED_OFF)
> return 0;
>
> + pmbus_set_page(psu->client, 0);
> +
> rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
> CFFPS_LED_BLINK);
> if (rc < 0)
> @@ -328,15 +359,32 @@ static void ibm_cffps_create_led_class(struct ibm_cffps *psu)
> dev_warn(dev, "failed to register led class: %d\n", rc);
> }
>
> -static struct pmbus_driver_info ibm_cffps_info = {
> - .pages = 1,
> - .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
> - PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
> - PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT |
> - PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
> - PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12,
> - .read_byte_data = ibm_cffps_read_byte_data,
> - .read_word_data = ibm_cffps_read_word_data,
> +static struct pmbus_driver_info ibm_cffps_info[] = {
> + [cffps1] = {
> + .pages = 1,
> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
> + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
> + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
> + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
> + PMBUS_HAVE_STATUS_FAN12,
> + .read_byte_data = ibm_cffps_read_byte_data,
> + .read_word_data = ibm_cffps_read_word_data,
> + },
> + [cffps2] = {
> + .pages = 2,
> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
> + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
> + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
> + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
> + PMBUS_HAVE_STATUS_FAN12,
> + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
> + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT,
> + .read_byte_data = ibm_cffps_read_byte_data,
> + .read_word_data = ibm_cffps_read_word_data,
> + },
> };
>
> static struct pmbus_platform_data ibm_cffps_pdata = {
> @@ -347,12 +395,21 @@ static int ibm_cffps_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> int i, rc;
> + enum versions vs;
> struct dentry *debugfs;
> struct dentry *ibm_cffps_dir;
> struct ibm_cffps *psu;
> + const void *md = of_device_get_match_data(&client->dev);
> +
> + if (md)
> + vs = (enum versions)md;
> + else if (id)
> + vs = (enum versions)id->driver_data;
> + else
> + vs = cffps1;
>
> client->dev.platform_data = &ibm_cffps_pdata;
> - rc = pmbus_do_probe(client, id, &ibm_cffps_info);
> + rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs]);
> if (rc)
> return rc;
>
> @@ -364,6 +421,7 @@ static int ibm_cffps_probe(struct i2c_client *client,
> if (!psu)
> return 0;
>
> + psu->version = vs;
> psu->client = client;
> mutex_init(&psu->input_history.update_lock);
> psu->input_history.last_update = jiffies - HZ;
> @@ -405,13 +463,21 @@ static int ibm_cffps_probe(struct i2c_client *client,
> }
>
> static const struct i2c_device_id ibm_cffps_id[] = {
> - { "ibm_cffps1", 1 },
> + { "ibm_cffps1", cffps1 },
> + { "ibm_cffps2", cffps2 },
> {}
> };
> MODULE_DEVICE_TABLE(i2c, ibm_cffps_id);
>
> static const struct of_device_id ibm_cffps_of_match[] = {
> - { .compatible = "ibm,cffps1" },
> + {
> + .compatible = "ibm,cffps1",
> + .data = (void *)cffps1
> + },
> + {
> + .compatible = "ibm,cffps2",
> + .data = (void *)cffps2
> + },
> {}
> };
> MODULE_DEVICE_TABLE(of, ibm_cffps_of_match);
^ permalink raw reply
* [PATCH v2 1/3] dt-bindings: hwmon: Document ibm,cffps2 compatible string
From: Guenter Roeck @ 2019-08-31 15:26 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-2-git-send-email-eajames@linux.ibm.com>
On Fri, Aug 30, 2019 at 02:11:01PM -0500, Eddie James wrote:
> Document the compatible string for version 2 of the IBM CFFPS PSU.
>
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
Applied to hwmon-next. Note that we'll still need review from a DT maintainer.
I don't see any problems, but then who knows.
Thanks,
Guenter
> ---
> Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
> index f68a0a6..1036f65 100644
> --- a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
> +++ b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
> @@ -1,8 +1,10 @@
> -Device-tree bindings for IBM Common Form Factor Power Supply Version 1
> -----------------------------------------------------------------------
> +Device-tree bindings for IBM Common Form Factor Power Supply Versions 1 and 2
> +-----------------------------------------------------------------------------
>
> Required properties:
> - - compatible = "ibm,cffps1";
> + - compatible : Must be one of the following:
> + "ibm,cffps1"
> + "ibm,cffps2"
> - reg = < I2C bus address >; : Address of the power supply on the
> I2C bus.
>
^ permalink raw reply
* [PATCH v4 4/4] aspeed/watchdog: Add access_cs0 option for alt-boot
From: Guenter Roeck @ 2019-08-31 15:01 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190828102402.13155-5-i.mikhaylov@yadro.com>
On Wed, Aug 28, 2019 at 01:24:02PM +0300, Ivan Mikhaylov wrote:
> The option for the ast2400/2500 to get access to CS0 at runtime.
>
> Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> .../ABI/testing/sysfs-class-watchdog | 34 +++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-class-watchdog b/Documentation/ABI/testing/sysfs-class-watchdog
> index 6317ade5ad19..675f9b537661 100644
> --- a/Documentation/ABI/testing/sysfs-class-watchdog
> +++ b/Documentation/ABI/testing/sysfs-class-watchdog
> @@ -72,3 +72,37 @@ Description:
> It is a read/write file. When read, the currently assigned
> pretimeout governor is returned. When written, it sets
> the pretimeout governor.
> +
> +What: /sys/class/watchdog/watchdog1/access_cs0
> +Date: August 2019
> +Contact: Ivan Mikhaylov <i.mikhaylov@yadro.com>,
> + Alexander Amelkin <a.amelkin@yadro.com>
> +Description:
> + It is a read/write file. This attribute exists only if the
> + system has booted from the alternate flash chip due to
> + expiration of a watchdog timer of AST2400/AST2500 when
> + alternate boot function was enabled with 'aspeed,alt-boot'
> + devicetree option for that watchdog or with an appropriate
> + h/w strapping (for WDT2 only).
> +
> + At alternate flash the 'access_cs0' sysfs node provides:
> + ast2400: a way to get access to the primary SPI flash
> + chip at CS0 after booting from the alternate
> + chip at CS1.
> + ast2500: a way to restore the normal address mapping
> + from (CS0->CS1, CS1->CS0) to (CS0->CS0,
> + CS1->CS1).
> +
> + Clearing the boot code selection and timeout counter also
> + resets to the initial state the chip select line mapping. When
> + the SoC is in normal mapping state (i.e. booted from CS0),
> + clearing those bits does nothing for both versions of the SoC.
> + For alternate boot mode (booted from CS1 due to wdt2
> + expiration) the behavior differs as described above.
> +
> + This option can be used with wdt2 (watchdog1) only.
> +
> + When read, the current status of the boot code selection is
> + shown. When written with any non-zero value, it clears
> + the boot code selection and the timeout counter, which results
> + in chipselect reset for AST2400/AST2500.
^ permalink raw reply
* [PATCH v4 3/4] watchdog/aspeed: add support for dual boot
From: Guenter Roeck @ 2019-08-31 15:01 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190828102402.13155-4-i.mikhaylov@yadro.com>
On Wed, Aug 28, 2019 at 01:24:01PM +0300, Ivan Mikhaylov wrote:
> Set WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION into WDT_CLEAR_TIMEOUT_STATUS
> to clear out boot code source and re-enable access to the primary SPI flash
> chip while booted via wdt2 from the alternate chip.
>
> AST2400 datasheet says:
> "In the 2nd flash booting mode, all the address mapping to CS0# would be
> re-directed to CS1#. And CS0# is not accessible under this mode. To access
> CS0#, firmware should clear the 2nd boot mode register in the WDT2 status
> register WDT30.bit[1]."
>
> Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/aspeed_wdt.c | 65 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
> index cc71861e033a..125dbd349b00 100644
> --- a/drivers/watchdog/aspeed_wdt.c
> +++ b/drivers/watchdog/aspeed_wdt.c
> @@ -53,6 +53,8 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table);
> #define WDT_CTRL_ENABLE BIT(0)
> #define WDT_TIMEOUT_STATUS 0x10
> #define WDT_TIMEOUT_STATUS_BOOT_SECONDARY BIT(1)
> +#define WDT_CLEAR_TIMEOUT_STATUS 0x14
> +#define WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION BIT(0)
>
> /*
> * WDT_RESET_WIDTH controls the characteristics of the external pulse (if
> @@ -165,6 +167,60 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd,
> return 0;
> }
>
> +/* access_cs0 shows if cs0 is accessible, hence the reverted bit */
> +static ssize_t access_cs0_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct aspeed_wdt *wdt = dev_get_drvdata(dev);
> + u32 status = readl(wdt->base + WDT_TIMEOUT_STATUS);
> +
> + return sprintf(buf, "%u\n",
> + !(status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY));
> +}
> +
> +static ssize_t access_cs0_store(struct device *dev,
> + struct device_attribute *attr, const char *buf,
> + size_t size)
> +{
> + struct aspeed_wdt *wdt = dev_get_drvdata(dev);
> + unsigned long val;
> +
> + if (kstrtoul(buf, 10, &val))
> + return -EINVAL;
> +
> + if (val)
> + writel(WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION,
> + wdt->base + WDT_CLEAR_TIMEOUT_STATUS);
> +
> + return size;
> +}
> +
> +/*
> + * This attribute exists only if the system has booted from the alternate
> + * flash with 'alt-boot' option.
> + *
> + * At alternate flash the 'access_cs0' sysfs node provides:
> + * ast2400: a way to get access to the primary SPI flash chip at CS0
> + * after booting from the alternate chip at CS1.
> + * ast2500: a way to restore the normal address mapping from
> + * (CS0->CS1, CS1->CS0) to (CS0->CS0, CS1->CS1).
> + *
> + * Clearing the boot code selection and timeout counter also resets to the
> + * initial state the chip select line mapping. When the SoC is in normal
> + * mapping state (i.e. booted from CS0), clearing those bits does nothing for
> + * both versions of the SoC. For alternate boot mode (booted from CS1 due to
> + * wdt2 expiration) the behavior differs as described above.
> + *
> + * This option can be used with wdt2 (watchdog1) only.
> + */
> +static DEVICE_ATTR_RW(access_cs0);
> +
> +static struct attribute *bswitch_attrs[] = {
> + &dev_attr_access_cs0.attr,
> + NULL
> +};
> +ATTRIBUTE_GROUPS(bswitch);
> +
> static const struct watchdog_ops aspeed_wdt_ops = {
> .start = aspeed_wdt_start,
> .stop = aspeed_wdt_stop,
> @@ -306,9 +362,16 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
> }
>
> status = readl(wdt->base + WDT_TIMEOUT_STATUS);
> - if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY)
> + if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) {
> wdt->wdd.bootstatus = WDIOF_CARDRESET;
>
> + if (of_device_is_compatible(np, "aspeed,ast2400-wdt") ||
> + of_device_is_compatible(np, "aspeed,ast2500-wdt"))
> + wdt->wdd.groups = bswitch_groups;
> + }
> +
> + dev_set_drvdata(dev, wdt);
> +
> return devm_watchdog_register_device(dev, &wdt->wdd);
> }
>
^ permalink raw reply
* [PATCH v2 1/2] dt-bindings: watchdog: Add ast2600 compatible
From: Guenter Roeck @ 2019-08-31 14:52 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190819051738.17370-2-joel@jms.id.au>
On Mon, Aug 19, 2019 at 02:47:37PM +0930, Joel Stanley wrote:
> This adds a compatible for the ast2600, a new ASPEED SoC.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
> Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2:
> - Add Andrew's r-b
> ---
> Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt b/Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt
> index c5077a1f5cb3..d78d4a8fb868 100644
> --- a/Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt
> +++ b/Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt
> @@ -4,6 +4,7 @@ Required properties:
> - compatible: must be one of:
> - "aspeed,ast2400-wdt"
> - "aspeed,ast2500-wdt"
> + - "aspeed,ast2600-wdt"
>
> - reg: physical base address of the controller and length of memory mapped
> region
^ permalink raw reply
* [PATCH v2 3/3] pmbus: ibm-cffps: Add support for version 2 of the PSU
From: Eddie James @ 2019-08-30 19:11 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-1-git-send-email-eajames@linux.ibm.com>
Version 2 of the PSU supports a second page of data and changes the
format of the FW version. Use the devicetree binding to differentiate
between the version the driver should use.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
Changes since v1:
- use an enum for the version instead of integers 1, 2, etc
drivers/hwmon/pmbus/ibm-cffps.c | 110 ++++++++++++++++++++++++++++++++--------
1 file changed, 88 insertions(+), 22 deletions(-)
diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index ee2ee9e..d44745e 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -12,6 +12,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of_device.h>
#include <linux/pmbus.h>
#include "pmbus.h"
@@ -20,8 +21,9 @@
#define CFFPS_PN_CMD 0x9B
#define CFFPS_SN_CMD 0x9E
#define CFFPS_CCIN_CMD 0xBD
-#define CFFPS_FW_CMD_START 0xFA
-#define CFFPS_FW_NUM_BYTES 4
+#define CFFPS_FW_CMD 0xFA
+#define CFFPS1_FW_NUM_BYTES 4
+#define CFFPS2_FW_NUM_WORDS 3
#define CFFPS_SYS_CONFIG_CMD 0xDA
#define CFFPS_INPUT_HISTORY_CMD 0xD6
@@ -52,6 +54,8 @@ enum {
CFFPS_DEBUGFS_NUM_ENTRIES
};
+enum versions { cffps1, cffps2 };
+
struct ibm_cffps_input_history {
struct mutex update_lock;
unsigned long last_update;
@@ -61,6 +65,7 @@ struct ibm_cffps_input_history {
};
struct ibm_cffps {
+ enum versions version;
struct i2c_client *client;
struct ibm_cffps_input_history input_history;
@@ -132,6 +137,8 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
struct ibm_cffps *psu = to_psu(idxp, idx);
char data[I2C_SMBUS_BLOCK_MAX] = { 0 };
+ pmbus_set_page(psu->client, 0);
+
switch (idx) {
case CFFPS_DEBUGFS_INPUT_HISTORY:
return ibm_cffps_read_input_history(psu, buf, count, ppos);
@@ -152,16 +159,36 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
rc = snprintf(data, 5, "%04X", rc);
goto done;
case CFFPS_DEBUGFS_FW:
- for (i = 0; i < CFFPS_FW_NUM_BYTES; ++i) {
- rc = i2c_smbus_read_byte_data(psu->client,
- CFFPS_FW_CMD_START + i);
- if (rc < 0)
- return rc;
+ switch (psu->version) {
+ case cffps1:
+ for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) {
+ rc = i2c_smbus_read_byte_data(psu->client,
+ CFFPS_FW_CMD +
+ i);
+ if (rc < 0)
+ return rc;
+
+ snprintf(&data[i * 2], 3, "%02X", rc);
+ }
- snprintf(&data[i * 2], 3, "%02X", rc);
- }
+ rc = i * 2;
+ break;
+ case cffps2:
+ for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) {
+ rc = i2c_smbus_read_word_data(psu->client,
+ CFFPS_FW_CMD +
+ i);
+ if (rc < 0)
+ return rc;
+
+ snprintf(&data[i * 4], 5, "%04X", rc);
+ }
- rc = i * 2;
+ rc = i * 4;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
goto done;
default:
return -EINVAL;
@@ -279,6 +306,8 @@ static void ibm_cffps_led_brightness_set(struct led_classdev *led_cdev,
psu->led_state = CFFPS_LED_ON;
}
+ pmbus_set_page(psu->client, 0);
+
rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
psu->led_state);
if (rc < 0)
@@ -299,6 +328,8 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
if (led_cdev->brightness == LED_OFF)
return 0;
+ pmbus_set_page(psu->client, 0);
+
rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
CFFPS_LED_BLINK);
if (rc < 0)
@@ -328,15 +359,32 @@ static void ibm_cffps_create_led_class(struct ibm_cffps *psu)
dev_warn(dev, "failed to register led class: %d\n", rc);
}
-static struct pmbus_driver_info ibm_cffps_info = {
- .pages = 1,
- .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
- PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
- PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT |
- PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
- PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12,
- .read_byte_data = ibm_cffps_read_byte_data,
- .read_word_data = ibm_cffps_read_word_data,
+static struct pmbus_driver_info ibm_cffps_info[] = {
+ [cffps1] = {
+ .pages = 1,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
+ PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
+ PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
+ PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
+ PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
+ PMBUS_HAVE_STATUS_FAN12,
+ .read_byte_data = ibm_cffps_read_byte_data,
+ .read_word_data = ibm_cffps_read_word_data,
+ },
+ [cffps2] = {
+ .pages = 2,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
+ PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
+ PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
+ PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
+ PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
+ PMBUS_HAVE_STATUS_FAN12,
+ .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
+ PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT,
+ .read_byte_data = ibm_cffps_read_byte_data,
+ .read_word_data = ibm_cffps_read_word_data,
+ },
};
static struct pmbus_platform_data ibm_cffps_pdata = {
@@ -347,12 +395,21 @@ static int ibm_cffps_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int i, rc;
+ enum versions vs;
struct dentry *debugfs;
struct dentry *ibm_cffps_dir;
struct ibm_cffps *psu;
+ const void *md = of_device_get_match_data(&client->dev);
+
+ if (md)
+ vs = (enum versions)md;
+ else if (id)
+ vs = (enum versions)id->driver_data;
+ else
+ vs = cffps1;
client->dev.platform_data = &ibm_cffps_pdata;
- rc = pmbus_do_probe(client, id, &ibm_cffps_info);
+ rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs]);
if (rc)
return rc;
@@ -364,6 +421,7 @@ static int ibm_cffps_probe(struct i2c_client *client,
if (!psu)
return 0;
+ psu->version = vs;
psu->client = client;
mutex_init(&psu->input_history.update_lock);
psu->input_history.last_update = jiffies - HZ;
@@ -405,13 +463,21 @@ static int ibm_cffps_probe(struct i2c_client *client,
}
static const struct i2c_device_id ibm_cffps_id[] = {
- { "ibm_cffps1", 1 },
+ { "ibm_cffps1", cffps1 },
+ { "ibm_cffps2", cffps2 },
{}
};
MODULE_DEVICE_TABLE(i2c, ibm_cffps_id);
static const struct of_device_id ibm_cffps_of_match[] = {
- { .compatible = "ibm,cffps1" },
+ {
+ .compatible = "ibm,cffps1",
+ .data = (void *)cffps1
+ },
+ {
+ .compatible = "ibm,cffps2",
+ .data = (void *)cffps2
+ },
{}
};
MODULE_DEVICE_TABLE(of, ibm_cffps_of_match);
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 2/3] ARM: dts: aspeed: swift: Change power supplies to version 2
From: Eddie James @ 2019-08-30 19:11 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-1-git-send-email-eajames@linux.ibm.com>
Swift power supplies are version 2 of the IBM CFFPS. Make it so in the
devicetree.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts
index f14f745..815b865 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts
@@ -494,7 +494,7 @@
};
power-supply at 68 {
- compatible = "ibm,cffps1";
+ compatible = "ibm,cffps2";
reg = <0x68>;
};
@@ -504,7 +504,7 @@
};
power-supply at 69 {
- compatible = "ibm,cffps1";
+ compatible = "ibm,cffps2";
reg = <0x69>;
};
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 1/3] dt-bindings: hwmon: Document ibm, cffps2 compatible string
From: Eddie James @ 2019-08-30 19:11 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <1567192263-15065-1-git-send-email-eajames@linux.ibm.com>
Document the compatible string for version 2 of the IBM CFFPS PSU.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
index f68a0a6..1036f65 100644
--- a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
+++ b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
@@ -1,8 +1,10 @@
-Device-tree bindings for IBM Common Form Factor Power Supply Version 1
-----------------------------------------------------------------------
+Device-tree bindings for IBM Common Form Factor Power Supply Versions 1 and 2
+-----------------------------------------------------------------------------
Required properties:
- - compatible = "ibm,cffps1";
+ - compatible : Must be one of the following:
+ "ibm,cffps1"
+ "ibm,cffps2"
- reg = < I2C bus address >; : Address of the power supply on the
I2C bus.
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 0/3] pmbus: ibm-cffps: Add support for version 2 of PSU
From: Eddie James @ 2019-08-30 19:11 UTC (permalink / raw)
To: linux-aspeed
Version 2 of this PSU supports a second page of data and changes the
format of the FW version command. Use the devicetree binding (or the I2C
device ID) to determine which version the driver should use. Therefore add
the new compatible string to the devicetree documentation and change the
Swift system devicetree to use version 2.
Changes since v1:
- use an enum for the version instead of integers 1, 2, etc
Eddie James (3):
dt-bindings: hwmon: Document ibm,cffps2 compatible string
ARM: dts: aspeed: swift: Change power supplies to version 2
pmbus: ibm-cffps: Add support for version 2 of the PSU
.../devicetree/bindings/hwmon/ibm,cffps1.txt | 8 +-
arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 4 +-
drivers/hwmon/pmbus/ibm-cffps.c | 110 ++++++++++++++++-----
3 files changed, 95 insertions(+), 27 deletions(-)
--
1.8.3.1
^ permalink raw reply
* [PATCH 3/3] pmbus: ibm-cffps: Add support for version 2 of the PSU
From: Eddie James @ 2019-08-30 18:19 UTC (permalink / raw)
To: linux-aspeed
In-Reply-To: <20190830173603.GA10472@roeck-us.net>
On 8/30/19 12:36 PM, Guenter Roeck wrote:
> On Fri, Aug 30, 2019 at 11:09:45AM -0500, Eddie James wrote:
>> Version 2 of the PSU supports a second page of data and changes the
>> format of the FW version. Use the devicetree binding to differentiate
>> between the version the driver should use.
>>
>> Signed-off-by: Eddie James <eajames@linux.ibm.com>
>> ---
>> drivers/hwmon/pmbus/ibm-cffps.c | 109 ++++++++++++++++++++++++++++++++--------
>> 1 file changed, 87 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
>> index ee2ee9e..ca26fbd 100644
>> --- a/drivers/hwmon/pmbus/ibm-cffps.c
>> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
>> @@ -12,16 +12,20 @@
>> #include <linux/leds.h>
>> #include <linux/module.h>
>> #include <linux/mutex.h>
>> +#include <linux/of_device.h>
>> #include <linux/pmbus.h>
>>
>> #include "pmbus.h"
>>
>> +#define CFFPS_VERSIONS 2
>> +
> Any chance you can use an enum for the versions ? Using version
> numbers 1/2 combined with array indices 0/1 is confusing, error
> prone, and seems unnecessary.
Sure, good idea.
Thanks,
Eddie
>
> Thanks,
> Guenter
>
>> #define CFFPS_FRU_CMD 0x9A
>> #define CFFPS_PN_CMD 0x9B
>> #define CFFPS_SN_CMD 0x9E
>> #define CFFPS_CCIN_CMD 0xBD
>> -#define CFFPS_FW_CMD_START 0xFA
>> -#define CFFPS_FW_NUM_BYTES 4
>> +#define CFFPS_FW_CMD 0xFA
>> +#define CFFPS1_FW_NUM_BYTES 4
>> +#define CFFPS2_FW_NUM_WORDS 3
>> #define CFFPS_SYS_CONFIG_CMD 0xDA
>>
>> #define CFFPS_INPUT_HISTORY_CMD 0xD6
>> @@ -61,6 +65,7 @@ struct ibm_cffps_input_history {
>> };
>>
>> struct ibm_cffps {
>> + int version;
>> struct i2c_client *client;
>>
>> struct ibm_cffps_input_history input_history;
>> @@ -132,6 +137,8 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
>> struct ibm_cffps *psu = to_psu(idxp, idx);
>> char data[I2C_SMBUS_BLOCK_MAX] = { 0 };
>>
>> + pmbus_set_page(psu->client, 0);
>> +
>> switch (idx) {
>> case CFFPS_DEBUGFS_INPUT_HISTORY:
>> return ibm_cffps_read_input_history(psu, buf, count, ppos);
>> @@ -152,16 +159,36 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
>> rc = snprintf(data, 5, "%04X", rc);
>> goto done;
>> case CFFPS_DEBUGFS_FW:
>> - for (i = 0; i < CFFPS_FW_NUM_BYTES; ++i) {
>> - rc = i2c_smbus_read_byte_data(psu->client,
>> - CFFPS_FW_CMD_START + i);
>> - if (rc < 0)
>> - return rc;
>> + switch (psu->version) {
>> + case 1:
>> + for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) {
>> + rc = i2c_smbus_read_byte_data(psu->client,
>> + CFFPS_FW_CMD +
>> + i);
>> + if (rc < 0)
>> + return rc;
>> +
>> + snprintf(&data[i * 2], 3, "%02X", rc);
>> + }
>>
>> - snprintf(&data[i * 2], 3, "%02X", rc);
>> - }
>> + rc = i * 2;
>> + break;
>> + case 2:
>> + for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) {
>> + rc = i2c_smbus_read_word_data(psu->client,
>> + CFFPS_FW_CMD +
>> + i);
>> + if (rc < 0)
>> + return rc;
>> +
>> + snprintf(&data[i * 4], 5, "%04X", rc);
>> + }
>>
>> - rc = i * 2;
>> + rc = i * 4;
>> + break;
>> + default:
>> + return -EOPNOTSUPP;
>> + }
>> goto done;
>> default:
>> return -EINVAL;
>> @@ -279,6 +306,8 @@ static void ibm_cffps_led_brightness_set(struct led_classdev *led_cdev,
>> psu->led_state = CFFPS_LED_ON;
>> }
>>
>> + pmbus_set_page(psu->client, 0);
>> +
>> rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
>> psu->led_state);
>> if (rc < 0)
>> @@ -299,6 +328,8 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
>> if (led_cdev->brightness == LED_OFF)
>> return 0;
>>
>> + pmbus_set_page(psu->client, 0);
>> +
>> rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
>> CFFPS_LED_BLINK);
>> if (rc < 0)
>> @@ -328,15 +359,32 @@ static void ibm_cffps_create_led_class(struct ibm_cffps *psu)
>> dev_warn(dev, "failed to register led class: %d\n", rc);
>> }
>>
>> -static struct pmbus_driver_info ibm_cffps_info = {
>> - .pages = 1,
>> - .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
>> - PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
>> - PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT |
>> - PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
>> - PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12,
>> - .read_byte_data = ibm_cffps_read_byte_data,
>> - .read_word_data = ibm_cffps_read_word_data,
>> +static struct pmbus_driver_info ibm_cffps_info[CFFPS_VERSIONS] = {
>> + [0] = {
>> + .pages = 1,
>> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
>> + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
>> + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
>> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
>> + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
>> + PMBUS_HAVE_STATUS_FAN12,
>> + .read_byte_data = ibm_cffps_read_byte_data,
>> + .read_word_data = ibm_cffps_read_word_data,
>> + },
>> + [1] = {
>> + .pages = 2,
>> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
>> + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
>> + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
>> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
>> + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP |
>> + PMBUS_HAVE_STATUS_FAN12,
>> + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
>> + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
>> + PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT,
>> + .read_byte_data = ibm_cffps_read_byte_data,
>> + .read_word_data = ibm_cffps_read_word_data,
>> + },
>> };
>>
>> static struct pmbus_platform_data ibm_cffps_pdata = {
>> @@ -346,13 +394,21 @@ static void ibm_cffps_create_led_class(struct ibm_cffps *psu)
>> static int ibm_cffps_probe(struct i2c_client *client,
>> const struct i2c_device_id *id)
>> {
>> - int i, rc;
>> + int i, rc, vs;
>> struct dentry *debugfs;
>> struct dentry *ibm_cffps_dir;
>> struct ibm_cffps *psu;
>> + const void *md = of_device_get_match_data(&client->dev);
>> +
>> + if (md)
>> + vs = (int)md;
>> + else if (id)
>> + vs = (int)id->driver_data;
>> + else
>> + vs = 1;
>>
>> client->dev.platform_data = &ibm_cffps_pdata;
>> - rc = pmbus_do_probe(client, id, &ibm_cffps_info);
>> + rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs - 1]);
>> if (rc)
>> return rc;
>>
>> @@ -364,6 +420,7 @@ static int ibm_cffps_probe(struct i2c_client *client,
>> if (!psu)
>> return 0;
>>
>> + psu->version = vs;
>> psu->client = client;
>> mutex_init(&psu->input_history.update_lock);
>> psu->input_history.last_update = jiffies - HZ;
>> @@ -406,12 +463,20 @@ static int ibm_cffps_probe(struct i2c_client *client,
>>
>> static const struct i2c_device_id ibm_cffps_id[] = {
>> { "ibm_cffps1", 1 },
>> + { "ibm_cffps2", 2 },
>> {}
>> };
>> MODULE_DEVICE_TABLE(i2c, ibm_cffps_id);
>>
>> static const struct of_device_id ibm_cffps_of_match[] = {
>> - { .compatible = "ibm,cffps1" },
>> + {
>> + .compatible = "ibm,cffps1",
>> + .data = (void *)1
>> + },
>> + {
>> + .compatible = "ibm,cffps2",
>> + .data = (void *)2
>> + },
>> {}
>> };
>> MODULE_DEVICE_TABLE(of, ibm_cffps_of_match);
>> --
>> 1.8.3.1
>>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox