Re: [RFC][PATCH] hwmon/max6650.c: Optionally retrieve voltage and prescaler from devicetree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  On 09-08-16 09:30, Mike Looijmans wrote:
  > Parse devicetree parameters for voltage and prescaler setting. This
  allows
  > using multiple max6550 devices with varying settings, and also makes
  it
  > possible to instantiate and configure the device using devicetree.
  >
  > Signed-off-by: Mike Looijmans <mike.looijmans@xxxxxxxx>
  > ---
  >
  > This patch just does the minimal to get the device working properly
  with
  > devicetree config.
  > What is the better path here, move to devicetree completely and
  remove the
  > module parameters,
  > or do we need to keep backward compatibility with the moduel
  parameter
  > (allowing only one
  > config for all chips)?
  > (in case of DT-only, the "clock" value could be obtained using the
  clock
  > framework)
  >
  > arch/arm/boot/dts/topic-miamiplus.dtsi |  1 +
  > drivers/hwmon/max6650.c                | 18 ++++++++++++++----
  > 2 files changed, 15 insertions(+), 4 deletions(-)
  >
  > diff --git a/arch/arm/boot/dts/topic-miamiplus.dtsi
  > b/arch/arm/boot/dts/topic-miamiplus.dtsi
  > index d433101..e927ff9 100644
  > --- a/arch/arm/boot/dts/topic-miamiplus.dtsi
  > +++ b/arch/arm/boot/dts/topic-miamiplus.dtsi
  > @@ -56,6 +56,7 @@
  >    reg = <0x1b>; /* ADD pins high-Z, hence address 0011011b */
  >    compatible = "max6650";
  >    voltage = <12>;
  > +  prescaler = <8>;
  >   };
  > };
  >
  Sorry, this part shouldn't have been in the patch!
  > diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
  > index 162a520..c190954 100644
  > --- a/drivers/hwmon/max6650.c
  > +++ b/drivers/hwmon/max6650.c
  > @@ -566,6 +566,15 @@ static int max6650_init_client(struct
  max6650_data *data,
  >   struct device *dev = &client->dev;
  >   int config;
  >   int err = -EIO;
  > + u32 local_fan_voltage = (u32)fan_voltage;
  > + u32 local_prescaler = (u32)prescaler;
  > +
  > +#ifdef CONFIG_OF
  > + of_property_read_u32(client->dev.of_node,
  > +        "voltage", &local_fan_voltage);
  > + of_property_read_u32(client->dev.of_node,
  > +        "prescaler", &local_prescaler);
  > +#endif
  >
  >   config = i2c_smbus_read_byte_data(client, MAX6650_REG_CONFIG);
  >
  > @@ -574,7 +583,7 @@ static int max6650_init_client(struct
  max6650_data *data,
  >    return err;
  >   }
  >
  > - switch (fan_voltage) {
  > + switch (local_fan_voltage) {
  >   case 0:
  >    break;
  >   case 5:
  > @@ -585,13 +594,13 @@ static int max6650_init_client(struct
  max6650_data *data,
  >    break;
  >   default:
  >    dev_err(dev, "illegal value for fan_voltage (%d)\n",
  > -   fan_voltage);
  > +   local_fan_voltage);
  >   }
  >
  >   dev_info(dev, "Fan voltage is set to %dV.\n",
  >     (config & MAX6650_CFG_V12) ? 12 : 5);
  >
  > - switch (prescaler) {
  > + switch (local_prescaler) {
  >   case 0:
  >    break;
  >   case 1:
  > @@ -614,7 +623,8 @@ static int max6650_init_client(struct
  max6650_data *data,
  >      | MAX6650_CFG_PRESCALER_16;
  >    break;
  >   default:
  > -  dev_err(dev, "illegal value for prescaler (%d)\n", prescaler);
  > +  dev_err(dev, "illegal value for prescaler (%d)\n",
  > +   local_prescaler);
  >   }
  >
  >   dev_info(dev, "Prescaler is set to %d.\n",
  > --
  > 1.9.1
  >
  > Kind regards,
  >
  > Mike Looijmans
  >
  > System Expert
  >
  >
  >
  > *TOPIC Products*
  >
  >
  >
  >
  >
  > Materiaalweg 4
  >
  >
  >
  >
  >
  > 5681 RJ Best
  >
  >
  >
  > T:
  >
  >
  >
  > +31 (0) 499 33 69 69
  >
  > Postbus 440
  >
  >
  >
  > E:
  >
  >
  >
  > mike.looijmans@xxxxxxxxxxxxxxxxx
  >
  > 5680 AK Best
  >
  >
  >
  > W:
  >
  >
  >
  > www.topicproducts.com <http://www.topicproducts.com>
  >
  > The Netherlands
  >
  >
  <https://www.facebook.com/TopicProducts><https://twitter.com/TopicProdu
  cts><https://www.linkedin.com/company/topic-embedded-products>
  > Please consider the environment before printing this e-mail
  >
  >
  > Topic zoekt gedreven (embedded) software specialisten!
  > <http://topic.nl/vacancy/topic-zoekt-technische-software-engineers/>
  >


  Kind regards,


  Mike Looijmans

  System Expert


  [cid:image7b51d0.PNG@75fc36a7.42abb6a5]

  TOPIC Products



  Materiaalweg 4



  5681 RJ Best

  T:

  +31 (0) 499 33 69 69

  Postbus 440

  E:

  mike.looijmans@xxxxxxxxxxxxxxxxx

  5680 AK Best

  W:

  [1]www.topicproducts.com
  The Netherlands

  [2][cid:image5918f1.JPG@f0d6511e.41b1bb4a]
  [3][cid:imagee19573.JPG@4027c0fd.4f82d4c9]
  [4][cid:image85634d.JPG@20a8dbe1.41be85a6]
  Please consider the environment before printing this e-mail
  [5]Topic zoekt gedreven (embedded) software specialisten!

References

  1. http://www.topicproducts.com/
  2. https://www.facebook.com/TopicProducts
  3. https://twitter.com/TopicProducts
  4. https://www.linkedin.com/company/topic-embedded-products
  5. http://topic.nl/vacancy/topic-zoekt-technische-software-engineers/

PNG image

JPEG image

JPEG image

JPEG image

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux