diff for duplicates of <4F8302A8.4050901@free-electrons.com> diff --git a/a/1.txt b/N1/1.txt index 0d86cae..dc5bf93 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,6 +1,6 @@ Hi, -Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a =E9crit : +Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a ?crit : > On 18:01 Thu 05 Apr , Maxime Ripard wrote: >> Add the IIO driver for the AT91 ADCs. It only supports and has >> been tested on the SAM9G20 evaluation boards, but support for @@ -21,20 +21,18 @@ Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a =E9crit : >> --- >> drivers/staging/iio/adc/Kconfig | 6 + >> drivers/staging/iio/adc/Makefile | 1 + ->> drivers/staging/iio/adc/at91_adc.c | 382 +++++++++++++++++++++++++++= -+++++++++ +>> drivers/staging/iio/adc/at91_adc.c | 382 ++++++++++++++++++++++++++++++++++++ >> 3 files changed, 389 insertions(+), 0 deletions(-) >> create mode 100644 drivers/staging/iio/adc/at91_adc.c >> ->> diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc= -/Kconfig +>> diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig >> index 592eabd..1494838 100644 >> --- a/drivers/staging/iio/adc/Kconfig >> +++ b/drivers/staging/iio/adc/Kconfig >> @@ -169,6 +169,12 @@ config AD7280 >> To compile this driver as a module, choose M here: the >> module will be called ad7280a ->> =20 +>> >> +config AT91_ADC >> + tristate "Atmel AT91 ADC" >> + depends on SYSFS && ARCH_AT91 @@ -44,18 +42,16 @@ Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a =E9crit : >> config MAX1363 >> tristate "Maxim max1363 ADC driver" >> depends on I2C ->> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/ad= -c/Makefile +>> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile >> index f83ab95..8cb6d1c 100644 >> --- a/drivers/staging/iio/adc/Makefile >> +++ b/drivers/staging/iio/adc/Makefile ->> @@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) +=3D adt7310.o ->> obj-$(CONFIG_ADT7410) +=3D adt7410.o ->> obj-$(CONFIG_AD7280) +=3D ad7280a.o ->> obj-$(CONFIG_LPC32XX_ADC) +=3D lpc32xx_adc.o ->> +obj-$(CONFIG_AT91_ADC) +=3D at91_adc.o ->> diff --git a/drivers/staging/iio/adc/at91_adc.c b/drivers/staging/iio/= -adc/at91_adc.c +>> @@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o +>> obj-$(CONFIG_ADT7410) += adt7410.o +>> obj-$(CONFIG_AD7280) += ad7280a.o +>> obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o +>> +obj-$(CONFIG_AT91_ADC) += at91_adc.o +>> diff --git a/drivers/staging/iio/adc/at91_adc.c b/drivers/staging/iio/adc/at91_adc.c >> new file mode 100644 >> index 0000000..c76516a >> --- /dev/null @@ -93,8 +89,7 @@ adc/at91_adc.c >> + * struct at91_adc_desc - description of the ADC on the board >> + * @clock: ADC clock as specified by the datasheet, in Hz. >> + * @clock_name Name of the ADC clock as defined in the clock tree ->> + * @num_channels: global number of channels available on the board (t= -o +>> + * @num_channels: global number of channels available on the board (to >> + specify which channels are indeed in use on the >> + board, see the channels_used bitmask in the platform >> + data) @@ -120,15 +115,15 @@ o >> + wait_queue_head_t wq_data_avail; >> +}; >> + ->> +static struct at91_adc_desc at91_adc_desc_sam9g20 =3D { ->> + .clock =3D 5000000, +>> +static struct at91_adc_desc at91_adc_desc_sam9g20 = { +>> + .clock = 5000000, > why 5Mhz? This is the value given by the datasheet of the G20 SoC. ->> + .clock_name =3D "adc_clk", ->> + .num_channels =3D 4, ->> + .startup_time =3D 10, +>> + .clock_name = "adc_clk", +>> + .num_channels = 4, +>> + .startup_time = 10, >> +}; >> + > this is soc specific nedd to be in the soc not in the driver @@ -144,7 +139,7 @@ SoC files. >> +static int at91_adc_select_soc(struct at91_adc_state *st) >> +{ >> + if (cpu_is_at91sam9g20()) { ->> + st->desc =3D &at91_adc_desc_sam9g20; +>> + st->desc = &at91_adc_desc_sam9g20; >> + return 0; >> + } >> + @@ -152,7 +147,7 @@ SoC files. >> +} > ditto >> + ->=20 +> >> + >> +static int __devinit at91_adc_probe(struct platform_device *pdev) >> +{ @@ -161,53 +156,53 @@ SoC files. >> + struct iio_dev *idev; >> + struct at91_adc_state *st; >> + struct resource *res; ->> + struct at91_adc_data *pdata =3D pdev->dev.platform_data; +>> + struct at91_adc_data *pdata = pdev->dev.platform_data; >> + ->> + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); +>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> + if (!res) { >> + dev_err(&pdev->dev, "No resource defined\n"); ->> + ret =3D -ENXIO; +>> + ret = -ENXIO; >> + goto error_ret; >> + } >> + ->> + idev =3D iio_allocate_device(sizeof(struct at91_adc_state)); ->> + if (idev =3D=3D NULL) { ->> + ret =3D -ENOMEM; +>> + idev = iio_allocate_device(sizeof(struct at91_adc_state)); +>> + if (idev == NULL) { +>> + ret = -ENOMEM; >> + goto error_ret; >> + } >> + >> + platform_set_drvdata(pdev, idev); >> + ->> + idev->dev.parent =3D &pdev->dev; ->> + idev->name =3D dev_name(&pdev->dev); ->> + idev->modes =3D INDIO_DIRECT_MODE; ->> + idev->info =3D &at91_adc_info; +>> + idev->dev.parent = &pdev->dev; +>> + idev->name = dev_name(&pdev->dev); +>> + idev->modes = INDIO_DIRECT_MODE; +>> + idev->info = &at91_adc_info; >> + ->> + st =3D iio_priv(idev); ->> + ret =3D at91_adc_select_soc(st); +>> + st = iio_priv(idev); +>> + ret = at91_adc_select_soc(st); >> + if (ret) { >> + dev_err(&pdev->dev, "SoC unknown\n"); >> + goto error_free_device; >> + } >> + ->> + st->irq =3D platform_get_irq(pdev, 0); +>> + st->irq = platform_get_irq(pdev, 0); >> + if (st->irq < 0) { >> + dev_err(&pdev->dev, "No IRQ ID is designated\n"); ->> + ret =3D -ENODEV; +>> + ret = -ENODEV; >> + goto error_free_device; >> + } >> + >> + if (!request_mem_region(res->start, resource_size(res), >> + "AT91 adc registers")) { >> + dev_err(&pdev->dev, "Resources are unavailable.\n"); ->> + ret =3D -EBUSY; +>> + ret = -EBUSY; >> + goto error_free_device; >> + } >> + ->> + st->reg_base =3D ioremap(res->start, resource_size(res)); +>> + st->reg_base = ioremap(res->start, resource_size(res)); >> + if (!st->reg_base) { >> + dev_err(&pdev->dev, "Failed to map registers.\n"); ->> + ret =3D -ENOMEM; +>> + ret = -ENOMEM; >> + goto error_release_mem; >> + } >> + @@ -216,7 +211,7 @@ SoC files. >> + */ >> + at91_adc_reg_write(st, AT91_ADC_CR, AT91_ADC_SWRST); >> + at91_adc_reg_write(st, AT91_ADC_IDR, 0xFFFFFFFF); ->> + ret =3D request_irq(st->irq, +>> + ret = request_irq(st->irq, >> + at91_adc_eoc_trigger, >> + 0, >> + pdev->dev.driver->name, @@ -226,14 +221,14 @@ SoC files. >> + goto error_unmap_reg; >> + } >> + ->> + st->clk =3D clk_get(&pdev->dev, st->desc->clock_name); +>> + st->clk = clk_get(&pdev->dev, st->desc->clock_name); > use a fixed clock name I can't. The clock name is "adc_clk" for the G20, "tsc_clk" for the G45. >> + if (IS_ERR(st->clk)) { >> + dev_err(&pdev->dev, "Failed to get the clock.\n"); ->> + ret =3D PTR_ERR(st->clk); +>> + ret = PTR_ERR(st->clk); >> + goto error_free_irq; >> + } >> + @@ -242,11 +237,11 @@ I can't. The clock name is "adc_clk" for the G20, "tsc_clk" for the G45. Ok, I will look into this. >> + clk_enable(st->clk); ->> + mstrclk =3D clk_get_rate(st->clk); +>> + mstrclk = clk_get_rate(st->clk); >> + >> + if (!pdata) { >> + dev_err(&pdev->dev, "No platform data available.\n"); ->> + ret =3D -EINVAL; +>> + ret = -EINVAL; >> + goto error_free_clk; >> + } > need to be check first @@ -256,7 +251,7 @@ Ok Thanks, Maxime ---=20 +-- Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. diff --git a/a/content_digest b/N1/content_digest index 820d9c9..99e53a6 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,21 +1,15 @@ "ref\01333641684-20325-1-git-send-email-maxime.ripard@free-electrons.com\0" "ref\01333641684-20325-3-git-send-email-maxime.ripard@free-electrons.com\0" "ref\020120407032742.GD16641@game.jcrosoft.org\0" - "From\0Maxime Ripard <maxime.ripard@free-electrons.com>\0" - "Subject\0Re: [PATCH 2/5] ARM: AT91: IIO: Add AT91 ADC driver.\0" + "From\0maxime.ripard@free-electrons.com (Maxime Ripard)\0" + "Subject\0[PATCH 2/5] ARM: AT91: IIO: Add AT91 ADC driver.\0" "Date\0Mon, 09 Apr 2012 17:39:20 +0200\0" - "To\0Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>\0" - "Cc\0linux-iio@vger.kernel.org" - linux-arm-kernel@lists.infradead.org - Nicolas Ferre <nicolas.ferre@atmel.com> - Patrice Vilchez <patrice.vilchez@atmel.com> - Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - " Jonathan Cameron <jic23@cam.ac.uk>\0" + "To\0linux-arm-kernel@lists.infradead.org\0" "\00:1\0" "b\0" "Hi,\n" "\n" - "Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a =E9crit :\n" + "Le 07/04/2012 05:27, Jean-Christophe PLAGNIOL-VILLARD a ?crit :\n" "> On 18:01 Thu 05 Apr , Maxime Ripard wrote:\n" ">> Add the IIO driver for the AT91 ADCs. It only supports and has\n" ">> been tested on the SAM9G20 evaluation boards, but support for\n" @@ -36,20 +30,18 @@ ">> ---\n" ">> drivers/staging/iio/adc/Kconfig | 6 +\n" ">> drivers/staging/iio/adc/Makefile | 1 +\n" - ">> drivers/staging/iio/adc/at91_adc.c | 382 +++++++++++++++++++++++++++=\n" - "+++++++++\n" + ">> drivers/staging/iio/adc/at91_adc.c | 382 ++++++++++++++++++++++++++++++++++++\n" ">> 3 files changed, 389 insertions(+), 0 deletions(-)\n" ">> create mode 100644 drivers/staging/iio/adc/at91_adc.c\n" ">>\n" - ">> diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc=\n" - "/Kconfig\n" + ">> diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig\n" ">> index 592eabd..1494838 100644\n" ">> --- a/drivers/staging/iio/adc/Kconfig\n" ">> +++ b/drivers/staging/iio/adc/Kconfig\n" ">> @@ -169,6 +169,12 @@ config AD7280\n" ">> \t To compile this driver as a module, choose M here: the\n" ">> \t module will be called ad7280a\n" - ">> =20\n" + ">> \n" ">> +config AT91_ADC\n" ">> +\ttristate \"Atmel AT91 ADC\"\n" ">> +\tdepends on SYSFS && ARCH_AT91\n" @@ -59,18 +51,16 @@ ">> config MAX1363\n" ">> \ttristate \"Maxim max1363 ADC driver\"\n" ">> \tdepends on I2C\n" - ">> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/ad=\n" - "c/Makefile\n" + ">> diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile\n" ">> index f83ab95..8cb6d1c 100644\n" ">> --- a/drivers/staging/iio/adc/Makefile\n" ">> +++ b/drivers/staging/iio/adc/Makefile\n" - ">> @@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) +=3D adt7310.o\n" - ">> obj-$(CONFIG_ADT7410) +=3D adt7410.o\n" - ">> obj-$(CONFIG_AD7280) +=3D ad7280a.o\n" - ">> obj-$(CONFIG_LPC32XX_ADC) +=3D lpc32xx_adc.o\n" - ">> +obj-$(CONFIG_AT91_ADC) +=3D at91_adc.o\n" - ">> diff --git a/drivers/staging/iio/adc/at91_adc.c b/drivers/staging/iio/=\n" - "adc/at91_adc.c\n" + ">> @@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o\n" + ">> obj-$(CONFIG_ADT7410) += adt7410.o\n" + ">> obj-$(CONFIG_AD7280) += ad7280a.o\n" + ">> obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o\n" + ">> +obj-$(CONFIG_AT91_ADC) += at91_adc.o\n" + ">> diff --git a/drivers/staging/iio/adc/at91_adc.c b/drivers/staging/iio/adc/at91_adc.c\n" ">> new file mode 100644\n" ">> index 0000000..c76516a\n" ">> --- /dev/null\n" @@ -108,8 +98,7 @@ ">> + * struct at91_adc_desc - description of the ADC on the board\n" ">> + * @clock:\t\tADC clock as specified by the datasheet, in Hz.\n" ">> + * @clock_name\t\tName of the ADC clock as defined in the clock tree\n" - ">> + * @num_channels:\tglobal number of channels available on the board (t=\n" - "o\n" + ">> + * @num_channels:\tglobal number of channels available on the board (to\n" ">> +\t\t\tspecify which channels are indeed in use on the\n" ">> +\t\t\tboard, see the channels_used bitmask in the platform\n" ">> +\t\t\tdata)\n" @@ -135,15 +124,15 @@ ">> +\twait_queue_head_t\twq_data_avail;\n" ">> +};\n" ">> +\n" - ">> +static struct at91_adc_desc at91_adc_desc_sam9g20 =3D {\n" - ">> +\t.clock =3D 5000000,\n" + ">> +static struct at91_adc_desc at91_adc_desc_sam9g20 = {\n" + ">> +\t.clock = 5000000,\n" "> why 5Mhz?\n" "\n" "This is the value given by the datasheet of the G20 SoC.\n" "\n" - ">> +\t.clock_name =3D \"adc_clk\",\n" - ">> +\t.num_channels =3D 4,\n" - ">> +\t.startup_time =3D 10,\n" + ">> +\t.clock_name = \"adc_clk\",\n" + ">> +\t.num_channels = 4,\n" + ">> +\t.startup_time = 10,\n" ">> +};\n" ">> +\n" "> this is soc specific nedd to be in the soc not in the driver\n" @@ -159,7 +148,7 @@ ">> +static int at91_adc_select_soc(struct at91_adc_state *st)\n" ">> +{\n" ">> +\tif (cpu_is_at91sam9g20()) {\n" - ">> +\t\tst->desc =3D &at91_adc_desc_sam9g20;\n" + ">> +\t\tst->desc = &at91_adc_desc_sam9g20;\n" ">> +\t\treturn 0;\n" ">> +\t}\n" ">> +\n" @@ -167,7 +156,7 @@ ">> +}\n" "> ditto\n" ">> +\n" - ">=20\n" + "> \n" ">> +\n" ">> +static int __devinit at91_adc_probe(struct platform_device *pdev)\n" ">> +{\n" @@ -176,53 +165,53 @@ ">> +\tstruct iio_dev *idev;\n" ">> +\tstruct at91_adc_state *st;\n" ">> +\tstruct resource *res;\n" - ">> +\tstruct at91_adc_data *pdata =3D pdev->dev.platform_data;\n" + ">> +\tstruct at91_adc_data *pdata = pdev->dev.platform_data;\n" ">> +\n" - ">> +\tres =3D platform_get_resource(pdev, IORESOURCE_MEM, 0);\n" + ">> +\tres = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n" ">> +\tif (!res) {\n" ">> +\t\tdev_err(&pdev->dev, \"No resource defined\\n\");\n" - ">> +\t\tret =3D -ENXIO;\n" + ">> +\t\tret = -ENXIO;\n" ">> +\t\tgoto error_ret;\n" ">> +\t}\n" ">> +\n" - ">> +\tidev =3D iio_allocate_device(sizeof(struct at91_adc_state));\n" - ">> +\tif (idev =3D=3D NULL) {\n" - ">> +\t\tret =3D -ENOMEM;\n" + ">> +\tidev = iio_allocate_device(sizeof(struct at91_adc_state));\n" + ">> +\tif (idev == NULL) {\n" + ">> +\t\tret = -ENOMEM;\n" ">> +\t\tgoto error_ret;\n" ">> +\t}\n" ">> +\n" ">> +\tplatform_set_drvdata(pdev, idev);\n" ">> +\n" - ">> +\tidev->dev.parent =3D &pdev->dev;\n" - ">> +\tidev->name =3D dev_name(&pdev->dev);\n" - ">> +\tidev->modes =3D INDIO_DIRECT_MODE;\n" - ">> +\tidev->info =3D &at91_adc_info;\n" + ">> +\tidev->dev.parent = &pdev->dev;\n" + ">> +\tidev->name = dev_name(&pdev->dev);\n" + ">> +\tidev->modes = INDIO_DIRECT_MODE;\n" + ">> +\tidev->info = &at91_adc_info;\n" ">> +\n" - ">> +\tst =3D iio_priv(idev);\n" - ">> +\tret =3D at91_adc_select_soc(st);\n" + ">> +\tst = iio_priv(idev);\n" + ">> +\tret = at91_adc_select_soc(st);\n" ">> +\tif (ret) {\n" ">> +\t\tdev_err(&pdev->dev, \"SoC unknown\\n\");\n" ">> +\t\tgoto error_free_device;\n" ">> +\t}\n" ">> +\n" - ">> +\tst->irq =3D platform_get_irq(pdev, 0);\n" + ">> +\tst->irq = platform_get_irq(pdev, 0);\n" ">> +\tif (st->irq < 0) {\n" ">> +\t\tdev_err(&pdev->dev, \"No IRQ ID is designated\\n\");\n" - ">> +\t\tret =3D -ENODEV;\n" + ">> +\t\tret = -ENODEV;\n" ">> +\t\tgoto error_free_device;\n" ">> +\t}\n" ">> +\n" ">> +\tif (!request_mem_region(res->start, resource_size(res),\n" ">> +\t\t\t\t\"AT91 adc registers\")) {\n" ">> +\t\tdev_err(&pdev->dev, \"Resources are unavailable.\\n\");\n" - ">> +\t\tret =3D -EBUSY;\n" + ">> +\t\tret = -EBUSY;\n" ">> +\t\tgoto error_free_device;\n" ">> +\t}\n" ">> +\n" - ">> +\tst->reg_base =3D ioremap(res->start, resource_size(res));\n" + ">> +\tst->reg_base = ioremap(res->start, resource_size(res));\n" ">> +\tif (!st->reg_base) {\n" ">> +\t\tdev_err(&pdev->dev, \"Failed to map registers.\\n\");\n" - ">> +\t\tret =3D -ENOMEM;\n" + ">> +\t\tret = -ENOMEM;\n" ">> +\t\tgoto error_release_mem;\n" ">> +\t}\n" ">> +\n" @@ -231,7 +220,7 @@ ">> +\t */\n" ">> +\tat91_adc_reg_write(st, AT91_ADC_CR, AT91_ADC_SWRST);\n" ">> +\tat91_adc_reg_write(st, AT91_ADC_IDR, 0xFFFFFFFF);\n" - ">> +\tret =3D request_irq(st->irq,\n" + ">> +\tret = request_irq(st->irq,\n" ">> +\t\t\t at91_adc_eoc_trigger,\n" ">> +\t\t\t 0,\n" ">> +\t\t\t pdev->dev.driver->name,\n" @@ -241,14 +230,14 @@ ">> +\t\tgoto error_unmap_reg;\n" ">> +\t}\n" ">> +\n" - ">> +\tst->clk =3D clk_get(&pdev->dev, st->desc->clock_name);\n" + ">> +\tst->clk = clk_get(&pdev->dev, st->desc->clock_name);\n" "> use a fixed clock name\n" "\n" "I can't. The clock name is \"adc_clk\" for the G20, \"tsc_clk\" for the G45.\n" "\n" ">> +\tif (IS_ERR(st->clk)) {\n" ">> +\t\tdev_err(&pdev->dev, \"Failed to get the clock.\\n\");\n" - ">> +\t\tret =3D PTR_ERR(st->clk);\n" + ">> +\t\tret = PTR_ERR(st->clk);\n" ">> +\t\tgoto error_free_irq;\n" ">> +\t}\n" ">> +\n" @@ -257,11 +246,11 @@ "Ok, I will look into this.\n" "\n" ">> +\tclk_enable(st->clk);\n" - ">> +\tmstrclk =3D clk_get_rate(st->clk);\n" + ">> +\tmstrclk = clk_get_rate(st->clk);\n" ">> +\n" ">> +\tif (!pdata) {\n" ">> +\t\tdev_err(&pdev->dev, \"No platform data available.\\n\");\n" - ">> +\t\tret =3D -EINVAL;\n" + ">> +\t\tret = -EINVAL;\n" ">> +\t\tgoto error_free_clk;\n" ">> +\t}\n" "> need to be check first\n" @@ -271,10 +260,10 @@ "Thanks,\n" "Maxime\n" "\n" - "--=20\n" + "-- \n" "Maxime Ripard, Free Electrons\n" "Kernel, drivers, real-time and embedded Linux\n" "development, consulting, training and support.\n" http://free-electrons.com -040fe802feb2821125bcdc3f563f5de4f07c8d078a0b940be21417e0c50fd8f9 +a45c8664898983e57d9ebc751d83b00f3948273fe6d77d074af264e9a607bc59
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.