From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 05/11] pmic: dm: Add support for MC34708 for PMIC DM
Date: Mon, 14 May 2018 12:01:26 +0200 [thread overview]
Message-ID: <20180514120126.7643f4d4@jawa> (raw)
In-Reply-To: <CAPnjgZ1WFYHXcrc=ZQzrc50XFP8-QqYX6M1Tg4Vg2eUx3Q73RQ@mail.gmail.com>
On Mon, 14 May 2018 08:01:45 +1000
Simon Glass <sjg@chromium.org> wrote:
> Hi Lukasz,
>
> On 7 May 2018 at 06:26, Lukasz Majewski <lukma@denx.de> wrote:
> > This patch adds support for MC34708 PMIC, to be used with driver
> > model (DM).
> >
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> >
> > ---
> >
> > Changes in v2:
> > - Support for uclass private data with trasfer length
> >
> > drivers/power/pmic/Kconfig | 7 +++
> > drivers/power/pmic/Makefile | 1 +
> > drivers/power/pmic/mc34708.c | 101
> > +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109
> > insertions(+) create mode 100644 drivers/power/pmic/mc34708.c
> >
> > diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
> > index 40ab9f7fa5..d504c28b77 100644
> > --- a/drivers/power/pmic/Kconfig
> > +++ b/drivers/power/pmic/Kconfig
> > @@ -69,6 +69,13 @@ config DM_PMIC_MAX8998
> > This config enables implementation of driver-model pmic
> > uclass features for PMIC MAX8998. The driver implements read/write
> > operations.
> >
> > +config DM_PMIC_MC34708
> > + bool "Enable Driver Model for PMIC MC34708"
> > + depends on DM_PMIC
> > + help
> > + This config enables implementation of driver-model pmic
> > uclass features
> > + for PMIC MC34708. The driver implements read/write
> > operations. +
> > config PMIC_MAX8997
> > bool "Enable Driver Model for PMIC MAX8997"
> > depends on DM_PMIC
> > diff --git a/drivers/power/pmic/Makefile
> > b/drivers/power/pmic/Makefile index ad32068b3a..418b5e7aee 100644
> > --- a/drivers/power/pmic/Makefile
> > +++ b/drivers/power/pmic/Makefile
> > @@ -8,6 +8,7 @@
> > obj-$(CONFIG_DM_PMIC) += pmic-uclass.o
> > obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
> > obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o
> > +obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.o
> > obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
> > obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o
> > obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
> > diff --git a/drivers/power/pmic/mc34708.c
> > b/drivers/power/pmic/mc34708.c new file mode 100644
> > index 0000000000..d9d1a41802
> > --- /dev/null
> > +++ b/drivers/power/pmic/mc34708.c
> > @@ -0,0 +1,101 @@
> > +/*
> > + * Copyright (C) 2018
> > + * Lukasz Majewski, DENX Software Engineering, lukma at denx.de
> > + *
> > + * SPDX-License-Identifier: GPL-2.0+
> > + */
> > +
> > +#include <common.h>
> > +#include <dm.h>
> > +#include <errno.h>
> > +#include <i2c.h>
> > +#include <power/pmic.h>
>
> should be at end
>
> > +#include <fsl_pmic.h>
>
> should be above i2c.h
>
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +static int mc34708_reg_count(struct udevice *dev)
> > +{
> > + return PMIC_NUM_OF_REGS;
> > +}
> > +
> > +static int mc34708_write(struct udevice *dev, uint reg, const u8
> > *buff,
> > + int len)
> > +{
> > + u8 buf[3] = { 0 };
> > + int ret;
> > +
> > + if (len != MC34708_TRANSFER_SIZE)
> > + return -EINVAL;
> > +
> > + buf[0] = buff[2];
> > + buf[1] = buff[1];
> > + buf[2] = buff[0];
>
> What is going on here? It deserves a comment at least.
This is the data endianess conversion for this chip (as described in
earlier reply). The upper layer (pmic-uclass) will receive data
formatted in little endian.
This unification can be leveraged with pmic_read/write generic
functions (as it is done latter).
>
> > +
> > + ret = dm_i2c_write(dev, reg, buf, len);
> > + if (ret)
> > + printf("write error to device: %p register: %#x!",
> > dev, reg); +
> > + return ret;
> > +}
> > +
>
> Regards,
> Simon
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180514/84d8b060/attachment.sig>
next prev parent reply other threads:[~2018-05-14 10:01 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-06 20:25 [U-Boot] [PATCH v2 00/11] pmic: sandbox: Add support for MC34709 PMIC Lukasz Majewski
2018-05-06 20:25 ` [U-Boot] [PATCH v2 01/11] pmic: fsl: Provide some more definitions for MC34708 PMIC Lukasz Majewski
2018-05-06 20:25 ` [U-Boot] [PATCH v2 02/11] pmic: fsl: Define number of bytes sent at once by " Lukasz Majewski
2018-05-13 22:01 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 03/11] pmic: Add support for setting transmission length in uclass private data Lukasz Majewski
2018-05-13 22:01 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 04/11] pmic: dm: Rewrite pmic_reg_{read|write|clrsetbits} to support 3 bytes transmissions Lukasz Majewski
2018-05-13 22:01 ` Simon Glass
2018-05-14 9:47 ` Lukasz Majewski
2018-05-06 20:26 ` [U-Boot] [PATCH v2 05/11] pmic: dm: Add support for MC34708 for PMIC DM Lukasz Majewski
2018-05-13 22:01 ` Simon Glass
2018-05-14 10:01 ` Lukasz Majewski [this message]
2018-05-06 20:26 ` [U-Boot] [PATCH v2 06/11] pmic: Rewrite the pmic command to not only work with single byte transmission Lukasz Majewski
2018-05-13 22:01 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 07/11] sandbox: Rewrite i2c_pmic_emul.c to support PMIC with 3 bytes transmission Lukasz Majewski
2018-05-13 22:02 ` Simon Glass
2018-05-14 10:46 ` Lukasz Majewski
2018-05-06 20:26 ` [U-Boot] [PATCH v2 08/11] sandbox: Enable support for MC34708 PMIC in DTS Lukasz Majewski
2018-05-06 20:35 ` Fabio Estevam
2018-05-07 14:12 ` Lukasz Majewski
2018-05-13 22:02 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 09/11] sandbox: Enable MC34708 PMIC support Lukasz Majewski
2018-05-13 22:02 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 10/11] sandbox: tests: Exclude common test code (pmic_get) in test/dm/pmic.c Lukasz Majewski
2018-05-13 22:02 ` Simon Glass
2018-05-06 20:26 ` [U-Boot] [PATCH v2 11/11] sandbox: tests: Add tests for mc34708 PMIC device Lukasz Majewski
2018-05-13 22:02 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180514120126.7643f4d4@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox