Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
On 05/10/2011 07:39 AM, Jason Liu wrote: Hi, Stefano, Hi Jason, 2011/4/27 Stefano Babic sba...@denx.de: On 04/27/2011 11:39 AM, Detlev Zundel wrote: Then why not rename the driver to something else than fsl_pmic? Maybe this is what Jason really is asking? Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point. Sorry for the late response due to some reason. :( No problem at all. Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea? I am open for new names. Probably we should state that this driver is a wrapper when SPI or I2C is used, and something like spi_i2c_pmic gives a better idea. With generic_pmic we could think there is a general layout for PMICs (and it is not true). Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Hi, Stefano, On Tue, May 10, 2011 at 4:35 PM, Stefano Babic sba...@denx.de wrote: On 05/10/2011 07:39 AM, Jason Liu wrote: Hi, Stefano, Hi Jason, 2011/4/27 Stefano Babic sba...@denx.de: On 04/27/2011 11:39 AM, Detlev Zundel wrote: Then why not rename the driver to something else than fsl_pmic? Maybe this is what Jason really is asking? Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point. Sorry for the late response due to some reason. :( No problem at all. Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea? I am open for new names. Probably we should state that this driver is a wrapper when SPI or I2C is used, and something like spi_i2c_pmic gives a better idea. With generic_pmic we could think there is a general layout for PMICs (and it is not true). OK, agree. I will change it to spi_i2c_pmic.c. :) Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Hi, Stefano, 2011/4/27 Stefano Babic sba...@denx.de: On 04/27/2011 11:39 AM, Detlev Zundel wrote: Then why not rename the driver to something else than fsl_pmic? Maybe this is what Jason really is asking? Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point. Sorry for the late response due to some reason. :( Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea? Jason Best regards, Stefano -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Hi Stefano, On 04/25/2011 04:59 AM, Jason Hui wrote: Hi, Stefano, Hi Jason, If you still want me to include the DA9053 support into fsl_pmic, could you please extend the fsl_pmic support to easily add another vender's pmic support first? Really I have not understood your question. What do you mean ? Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for freescale mc13xxx? Thanks, IMHO the details for each Power Controllers are inside the corresponding header, that contains the register description, in your xace DA09053.h. The fsl_pmic.c expones only a general way to speak with the controller via SPI or I2C interface. If I see your patch, the only real difference with the original file is that a single byte is read/written with the DA09053, while the mc13xxx have 32-bit registers. You can add this option as CONFIG_ switch, or in another way. Only the board is aware about which PMIC is used. In fact, the fsl_pmic.c does not include neither mc13892.h nor mc13783.h. Then why not rename the driver to something else than fsl_pmic? Maybe this is what Jason really is asking? I have not looked any deeper, but maybe something like i2c_pmic or such... Cheers Detlev -- Don't trust everything you read, and don't assume every poster in a thread is actually relevant to the problem. -- Stefan Monnier jwvlj1gk44h.fsf-monnier+em...@gnu.org -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: d...@denx.de ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
On 04/27/2011 11:39 AM, Detlev Zundel wrote: Then why not rename the driver to something else than fsl_pmic? Maybe this is what Jason really is asking? Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point. Best regards, Stefano -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
On 04/25/2011 04:59 AM, Jason Hui wrote: Hi, Stefano, Hi Jason, If you still want me to include the DA9053 support into fsl_pmic, could you please extend the fsl_pmic support to easily add another vender's pmic support first? Really I have not understood your question. What do you mean ? Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for freescale mc13xxx? Thanks, IMHO the details for each Power Controllers are inside the corresponding header, that contains the register description, in your xace DA09053.h. The fsl_pmic.c expones only a general way to speak with the controller via SPI or I2C interface. If I see your patch, the only real difference with the original file is that a single byte is read/written with the DA09053, while the mc13xxx have 32-bit registers. You can add this option as CONFIG_ switch, or in another way. Only the board is aware about which PMIC is used. In fact, the fsl_pmic.c does not include neither mc13892.h nor mc13783.h. Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Hi, Stefano, On Sat, Apr 23, 2011 at 3:45 PM, stefano babic sba...@denx.de wrote: Am 22/04/2011 16:50, schrieb Jason Liu: Hi Jason, As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ? I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are: - registers are 1 byte wide instead of 32 bit - different size of register area Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one. fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right? It was for MC13892, but it is for MC13783 as well, used in i.MX31 boards. As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch the original file and add one new file. The head of this file tell it clear that this patch is Based on drivers/misc/fsl_pmic.c. I do not mind an issue related to set where the driver is coming from. My concern is due to the fact that your patch is very similar (for the i2c part) to the fsl_pmic.c file, and I want to avoid to have two different driver making the same things, having then the necessity to maintain both. At the end, this file expones only a common interface to the board maintainers to access the pmic registers (via I2c or SPI as well). Running diff on the two files I do not see a lot of differences. If you still want me to include the DA9053 support into fsl_pmic, could you please extend the fsl_pmic support to easily add another vender's pmic support first? Really I have not understood your question. What do you mean ? Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for freescale mc13xxx? Thanks, Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Am 22/04/2011 16:50, schrieb Jason Liu: Hi Jason, As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ? I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are: - registers are 1 byte wide instead of 32 bit - different size of register area Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one. fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right? It was for MC13892, but it is for MC13783 as well, used in i.MX31 boards. As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch the original file and add one new file. The head of this file tell it clear that this patch is Based on drivers/misc/fsl_pmic.c. I do not mind an issue related to set where the driver is coming from. My concern is due to the fact that your patch is very similar (for the i2c part) to the fsl_pmic.c file, and I want to avoid to have two different driver making the same things, having then the necessity to maintain both. At the end, this file expones only a common interface to the board maintainers to access the pmic registers (via I2c or SPI as well). Running diff on the two files I do not see a lot of differences. If you still want me to include the DA9053 support into fsl_pmic, could you please extend the fsl_pmic support to easily add another vender's pmic support first? Really I have not understood your question. What do you mean ? Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Dear Jason Liu, In message banlktin-cud+y7meqyjf3w1jq49zzts...@mail.gmail.com you wrote: Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one. fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right? As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch the original file and add one new file. The head of this file tell it clear that this patch is Based on drivers/misc/fsl_pmic.c. Stefano is right. We cannot accept such duplication of code. Please merge into a single common driver. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de When people are least sure, they are often most dogmatic. - John Kenneth Galbraith ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Add dialog pmic(DA9053) driver with I2C interface support Signed-off-by: Jason Liu jason@linaro.org --- drivers/misc/Makefile |1 + drivers/misc/dialog_pmic.c | 123 + include/da9053.h | 186 3 files changed, 310 insertions(+), 0 deletions(-) diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index b152486..c557a14 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -35,6 +35,7 @@ COBJS-$(CONFIG_NS87308) += ns87308.o COBJS-$(CONFIG_PDSP188x) += pdsp188x.o COBJS-$(CONFIG_STATUS_LED) += status_led.o COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.o +COBJS-$(CONFIG_DIALOG_PMIC) += dialog_pmic.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/misc/dialog_pmic.c b/drivers/misc/dialog_pmic.c new file mode 100644 index 000..95dc6ea --- /dev/null +++ b/drivers/misc/dialog_pmic.c @@ -0,0 +1,123 @@ +/* + * (C) Copyright 2011 Freescale Semiconductor, Inc. + * Based on drivers/misc/fsl_pmic.c + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include config.h +#include common.h +#include i2c.h +#include asm/errno.h +#include linux/types.h + +static int check_param(u32 reg, u32 write) +{ + if (reg 142 || write 1) { + printf(reg num = %d is invalid. Should be less then 142\n, + reg); + return -1; + } + + return 0; +} + +static u32 pmic_reg(u32 reg, u32 val, u32 write) +{ + unsigned char buf[1] = { 0 }; + u32 ret_val = 0; + + if (check_param(reg, write)) + return -1; + + if (write) { + buf[0] = (val) 0xff; + if (i2c_write(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR, reg, 1, buf, 1)) + return -1; + } else { + if (i2c_read(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR, reg, 1, buf, 1)) + return -1; + ret_val = buf[0]; + } + + return ret_val; +} + +void pmic_reg_write(u32 reg, u32 value) +{ + pmic_reg(reg, value, 1); +} + +u32 pmic_reg_read(u32 reg) +{ + return pmic_reg(reg, 0, 0); +} + +static void pmic_dump(int numregs) +{ + u32 val; + int i; + + for (i = 0; i numregs; i++) { + val = pmic_reg_read(i); + if (!(i % 8)) + printf(\n0x%02x: , i); + printf(%02x , val); + } + puts(\n); +} + +int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + char *cmd; + int nregs; + u32 val; + + /* at least two arguments please */ + if (argc 2) + return cmd_usage(cmdtp); + + cmd = argv[1]; + if (strcmp(cmd, dump) == 0) { + if (argc 3) + return cmd_usage(cmdtp); + + nregs = simple_strtoul(argv[2], NULL, 16); + pmic_dump(nregs); + return 0; + } + if (strcmp(cmd, write) == 0) { + if (argc 4) + return cmd_usage(cmdtp); + + nregs = simple_strtoul(argv[2], NULL, 16); + val = simple_strtoul(argv[3], NULL, 16); + pmic_reg_write(nregs, val); + return 0; + } + /* No subcommand found */ + return 1; +} + +U_BOOT_CMD( + pmic, CONFIG_SYS_MAXARGS, 1, do_pmic, + Dialog PMIC (DA905x), + dump [numregs] dump registers\n + pmic write reg value - write register +); diff --git a/include/da9053.h b/include/da9053.h new file mode 100644 index 000..f69408a --- /dev/null +++ b/include/da9053.h @@ -0,0 +1,186 @@ +/* + * da9053 register declarations. + * + * Copyright(c) 2009 Dialog Semiconductor Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
On 04/22/2011 02:55 PM, Jason Liu wrote: Add dialog pmic(DA9053) driver with I2C interface support Hi Jason, diff --git a/drivers/misc/dialog_pmic.c b/drivers/misc/dialog_pmic.c new file mode 100644 index 000..95dc6ea --- /dev/null +++ b/drivers/misc/dialog_pmic.c @@ -0,0 +1,123 @@ +/* + * (C) Copyright 2011 Freescale Semiconductor, Inc. + * Based on drivers/misc/fsl_pmic.c As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ? I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are: - registers are 1 byte wide instead of 32 bit - different size of register area Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one. Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V6 2/3] PMIC: Add dialog pmic support
Hi, Stefano, 2011/4/22 Stefano Babic sba...@denx.de: On 04/22/2011 02:55 PM, Jason Liu wrote: Add dialog pmic(DA9053) driver with I2C interface support Hi Jason, diff --git a/drivers/misc/dialog_pmic.c b/drivers/misc/dialog_pmic.c new file mode 100644 index 000..95dc6ea --- /dev/null +++ b/drivers/misc/dialog_pmic.c @@ -0,0 +1,123 @@ +/* + * (C) Copyright 2011 Freescale Semiconductor, Inc. + * Based on drivers/misc/fsl_pmic.c As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ? I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are: - registers are 1 byte wide instead of 32 bit - different size of register area Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one. fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right? As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch the original file and add one new file. The head of this file tell it clear that this patch is Based on drivers/misc/fsl_pmic.c. If you still want me to include the DA9053 support into fsl_pmic, could you please extend the fsl_pmic support to easily add another vender's pmic support first? Jason Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot