ata: intf_platform_ide: add OF bindings
PATCH 1/1 ata: intf_platform_ide: add OF bindings
--- drivers/ata/intf_platform_ide.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
drivers/ata/intf_platform_ide.c +33 -2
@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice
@@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" ); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) { +dev_err (dev,"Platform data allocation failed\n" ); +return -ENOMEM ; + } +device_add_data (dev, pdata,sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );
@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 18 lines · On Thu, 3 Sep 2015 16:38:46 +0300 Peter Mamonov <[email protected]> wrote:
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/ata/intf_platform_ide.c +1
-0@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 90
Quoted 5 lines
drivers/ata/intf_platform_ide.c +2
-0@@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;
Can we move dn and tmp32 declarations under 'if (pdata == NULL) {' ?
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 101
Quoted 13 lines
drivers/ata/intf_platform_ide.c +9
-2if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" ); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) {
xzalloc() can't return NULL.
Please drop this 'if' operator.
Quoted 42 lines
drivers/ata/intf_platform_ide.c +21
-0+dev_err (dev,"Platform data allocation failed\n" ); +return -ENOMEM ; + } +device_add_data (dev, pdata,sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 50 lines · On Thu, 3 Sep 2015 17:24:55 +0300 Antony Pavlov <[email protected]> wrote:
Quoted 19 lines · On Thu, 3 Sep 2015 16:38:46 +0300 Peter Mamonov <[email protected]> wrote:
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35+++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
(quoted diff) +0
-0
b/drivers/ata/intf_platform_ide.cindex 0d392d8..f20e0e0 100644drivers/ata/intf_platform_ide.c +1
-0@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d · line 90
Quoted 5 lines
drivers/ata/intf_platform_ide.c +2
-0@@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev) void *reg_base, *alt_base = NULL;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;Can we move dn and tmp32 declarations under 'if (pdata == NULL) {' ?
Quoted 5 lines
drivers/ata/intf_platform_ide.c +0
-2if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n"); -return -EINVAL ;drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 101
Quoted 10 lines
drivers/ata/intf_platform_ide.c +9
-0+/* try to get platform data from the device tree */ +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n"); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) {
xzalloc()can't return NULL.Please drop this 'if' operator.
Quoted 14 lines
Quoted 11 lines
drivers/ata/intf_platform_ide.c +4
-0+dev_err (dev,"Platform data allocation failed\n"); +return -ENOMEM ; + } + device_add_data(dev, pdata, sizeof(struct
ide_port_info)); +drivers/ata/intf_platform_ide.c +4
-0+if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + + if (of_property_read_u32(dn, "reg-shift", &tmp32)== 0)
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 113
Quoted 3 lines
drivers/ata/intf_platform_ide.c +3
-0+ pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata;
This line is also excessive. device_add_data() have already done the job.
Quoted 22 lines
Quoted 22 lines
drivers/ata/intf_platform_ide.c +9
-0} reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev) return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Quoted 10 lines
Quoted 8 lines
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/1 ata: intf_platform_ide: add OF bindings
In reply to Antony Pavlov--- drivers/ata/intf_platform_ide.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/ata/intf_platform_ide.c +28 -2
@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice
@@ -87,8 +88,24 @@ static int platform_ide_probe(struct device_d *dev)int mmio =0 ;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +struct device_node *dn = dev->device_node; +u32 tmp32; + +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" ); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32; + +device_add_data (dev, pdata,sizeof (struct ide_port_info )); } reg_base =dev_request_mem_region (dev,0 );
@@ -136,9 +153,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 29 lines · Peter Mamonov
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)drivers/ata/intf_platform_ide.c +7
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -87,8 +88,24 @@ static int platform_ide_probe(struct device_d *dev)int mmio =0 ;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +struct device_node *dn = dev->device_node; +u32 tmp32; + +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" );
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 106
Quoted 10 lines
drivers/ata/intf_platform_ide.c +10
-0+return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32;
No need to allocate extra memory for platform_data which is solely used in this function. Please just use two local variables dataif_be and ioport_shift which you either fill in from platform_data or from device tree.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/1 ata: intf_platform_ide: add OF bindings
--- drivers/ata/intf_platform_ide.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/ata/intf_platform_ide.c +31 -5
@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice
@@ -85,8 +86,24 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; - -if (pdata ==NULL ) { +struct device_node *dn = dev->device_node; +unsigned ioport_shift =0 ; +int dataif_be =0 ; +void (*reset)(int ) =NULL ; + +if (pdata) { + ioport_shift = pdata->ioport_shift; + dataif_be = pdata->dataif_be; + reset = pdata->reset; + }else if (dn) { +/* try to get platform data from the device tree */ +u32 tmp32; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + ioport_shift = (unsigned )tmp32; +if (of_property_read_bool (dn,"dataif-be" )) + dataif_be =1 ; + }else {dev_err (dev,"No platform data. Cannot continue\n" );return -EINVAL ; }
@@ -123,9 +140,9 @@ static int platform_ide_probe(struct device_d *dev) ide =xzalloc (sizeof (*ide)); ide->io.mmio = mmio; -platform_ide_setup_port (reg_base, alt_base, &ide->io, pdata->ioport_shift); - ide->io.reset = pdata->reset; - ide->io.dataif_be = pdata->dataif_be; +platform_ide_setup_port (reg_base, alt_base, &ide->io, ioport_shift); + ide->io.reset = reset; + ide->io.dataif_be = dataif_be; rc =ide_port_register (ide);if (rc !=0 ) {
@@ -136,9 +153,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Am Montag, den 07.09.2015, 18:44 +0300 schrieb Peter Mamonov:
Quoted 28 lines
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)drivers/ata/intf_platform_ide.c +6
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,8 +86,24 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; - -if (pdata ==NULL ) { +struct device_node *dn = dev->device_node; +unsigned ioport_shift =0 ; +int dataif_be =0 ; +void (*reset)(int ) =NULL ; +
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 103
Quoted 10 lines
drivers/ata/intf_platform_ide.c +10
-0+if (pdata) { + ioport_shift = pdata->ioport_shift; + dataif_be = pdata->dataif_be; + reset = pdata->reset; + }else if (dn) { +/* try to get platform data from the device tree */ +u32 tmp32; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + ioport_shift = (unsigned )tmp32;
This is okay, as it's already used by the established precedent in Linux.
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 105
Quoted 2 lines
drivers/ata/intf_platform_ide.c +2
-0+if (of_property_read_bool (dn,"dataif-be" )) + dataif_be =1 ;
This is not okay, there is no precedent for this property in Linux and there is no binding specifying this property.
Quoted 36 lines
drivers/ata/intf_platform_ide.c +13
-3+ }else {dev_err (dev,"No platform data. Cannot continue\n" );return -EINVAL ; }@@ -123,9 +140,9 @@ static int platform_ide_probe(struct device_d *dev) ide =xzalloc (sizeof (*ide)); ide->io.mmio = mmio; -platform_ide_setup_port (reg_base, alt_base, &ide->io, pdata->ioport_shift); - ide->io.reset = pdata->reset; - ide->io.dataif_be = pdata->dataif_be; +platform_ide_setup_port (reg_base, alt_base, &ide->io, ioport_shift); + ide->io.reset = reset; + ide->io.dataif_be = dataif_be; rc =ide_port_register (ide);if (rc !=0 ) {@@ -136,9 +153,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 8 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v3 1/1 ata: intf_platform_ide: add OF bindings
--- drivers/ata/intf_platform_ide.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
drivers/ata/intf_platform_ide.c +29 -5
@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice
@@ -85,8 +86,22 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; - -if (pdata ==NULL ) { +struct device_node *dn = dev->device_node; +unsigned ioport_shift =0 ; +int dataif_be =0 ; +void (*reset)(int ) =NULL ; + +if (pdata) { + ioport_shift = pdata->ioport_shift; + dataif_be = pdata->dataif_be; + reset = pdata->reset; + }else if (dn) { +/* try to get platform data from the device tree */ +u32 tmp32; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + ioport_shift = (unsigned )tmp32; + }else {dev_err (dev,"No platform data. Cannot continue\n" );return -EINVAL ; }
@@ -123,9 +138,9 @@ static int platform_ide_probe(struct device_d *dev) ide =xzalloc (sizeof (*ide)); ide->io.mmio = mmio; -platform_ide_setup_port (reg_base, alt_base, &ide->io, pdata->ioport_shift); - ide->io.reset = pdata->reset; - ide->io.dataif_be = pdata->dataif_be; +platform_ide_setup_port (reg_base, alt_base, &ide->io, ioport_shift); + ide->io.reset = reset; + ide->io.dataif_be = dataif_be; rc =ide_port_register (ide);if (rc !=0 ) {
@@ -136,9 +151,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Peter,
Quoted 28 lines · Peter Mamonov
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)drivers/ata/intf_platform_ide.c +6
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,8 +86,22 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; - -if (pdata ==NULL ) { +struct device_node *dn = dev->device_node; +unsigned ioport_shift =0 ; +int dataif_be =0 ; +void (*reset)(int ) =NULL ; +
drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 103
Quoted 10 lines
drivers/ata/intf_platform_ide.c +10
-0+if (pdata) { + ioport_shift = pdata->ioport_shift; + dataif_be = pdata->dataif_be; + reset = pdata->reset; + }else if (dn) { +/* try to get platform data from the device tree */ +u32 tmp32; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + ioport_shift = (unsigned )tmp32;
Applied with one little change. We can simplify this by doing passing &ioport_shift directly to of_property_read_u32. We do not have to check the return value then.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Peter.
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Most likely your IDE controller is inside some SoC specific block, with a specific compatible, which may also handle clocks and other required stuff and that one should instantiate the IDE driver if needed.
Regards,
Lucas
Am Donnerstag, den 03.09.2015, 16:38 +0300 schrieb Peter Mamonov:
Quoted 70 lines
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/ata/intf_platform_ide.c +33
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" ); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) { +dev_err (dev,"Platform data allocation failed\n" ); +return -ENOMEM ; + } +device_add_data (dev, pdata,sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 8 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · On Thu, 03 Sep 2015 17:46:32 +0200 Lucas Stach <[email protected]> wrote:
Hi Peter.
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Hmmm. in linux-4.2/drivers/ata/pata_of_platform.c I see "ata-generic" with "reg-shift" and "pio-mode" properties.
Quoted 88 lines
Most likely your IDE controller is inside some SoC specific block, with a specific compatible, which may also handle clocks and other required stuff and that one should instantiate the IDE driver if needed.
Regards,
LucasAm Donnerstag, den 03.09.2015, 16:38 +0300 schrieb Peter Mamonov:
Quoted 70 lines
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)drivers/ata/intf_platform_ide.c +33
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev)void *reg_base, *alt_base =NULL ;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n" ); -return -EINVAL ; +/* try to get platform data from the device tree */ +if (dn ==NULL ) { +dev_err (dev,"No platform data. Cannot continue\n" ); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) { +dev_err (dev,"Platform data allocation failed\n" ); +return -ENOMEM ; + } +device_add_data (dev, pdata,sizeof (struct ide_port_info )); + +if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + +if (of_property_read_u32 (dn,"reg-shift" , &tmp32) ==0 ) + pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev)return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);Signature · 8 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 9 lines · Antony Pavlov
Quoted 6 lines · On Thu, 03 Sep 2015 17:46:32 +0200 Lucas Stach <[email protected]> wrote:
Hi Peter.
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
Quoted 5 lines
Quoted 2 lines
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Hmmm. in
linux-4.2/drivers/ata/pata_of_platform.cI see "ata-generic" with "reg-shift" and "pio-mode" properties.
It seems this binding comes from the good old days when writing binding doc was an optional task ;)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi, Sascha!
Quoted 13 lines · On Thu, 3 Sep 2015 20:16:36 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 12 lines · Antony Pavlov
Quoted 8 lines · On Thu, 03 Sep 2015 17:46:32 +0200 Lucas Stach <[email protected]> wrote:
Hi Peter.
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Quoted 8 lines
Quoted 2 lines
Hmmm. in
linux-4.2/drivers/ata/pata_of_platform.cI see "ata-generic" with "reg-shift" and "pio-mode" properties.It seems this binding comes from the good old days when writing binding doc was an optional task ;)
Sascha
So, do we need this linux-like binding in barebox, or should we prefer a soc-specific approach, as Lucas described:
Quoted 4 lines
Most likely your IDE controller is inside some SoC specific block, with a specific compatible, which may also handle clocks and other required stuff and that one should instantiate the IDE driver if needed.
?
Peter
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hi, Lucas!
Quoted 5 lines · On Thu, 03 Sep 2015 17:46:32 +0200 Lucas Stach <[email protected]> wrote:
Hi Peter.
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
Could you clarify your point? My current understanding is that drivers instantiation from a platform code and from a DT are equal approaches, which should mirror each other.
Quoted 8 lines
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Most likely your IDE controller is inside some SoC specific block, with a specific compatible, which may also handle clocks and other required stuff and that one should instantiate the IDE driver if needed.
I've got your point. However, drivers/ata/pata_of_platform.c from Linux also lacks any clock/stuff initialization.
Regards,
Peter
Quoted 65 lines
Regards,
LucasAm Donnerstag, den 03.09.2015, 16:38 +0300 schrieb Peter Mamonov:
Quoted 60 lines
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35+++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
(quoted diff) +0
-0
b/drivers/ata/intf_platform_ide.cindex 0d392d8..f20e0e0 100644drivers/ata/intf_platform_ide.c +16
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev) void *reg_base, *alt_base = NULL;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n"); -return -EINVAL ; + /* try to get platform data from the device tree */ + if (dn == NULL) { +dev_err (dev,"No platform data. Cannot continue\n"); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) { +dev_err (dev,"Platform data allocation failed\n"); +return -ENOMEM ; + } + device_add_data(dev, pdata, sizeof(struct
ide_port_info)); +drivers/ata/intf_platform_ide.c +4
-0+if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + + if (of_property_read_u32(dn, "reg-shift", &tmp32)== 0)
drivers/ata/intf_platform_ide.c +3
-0+ pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev) return rc; }
Quoted 16 lines
Quoted 5 lines
drivers/ata/intf_platform_ide.c +5
-0+static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ drivers/ata/intf_platform_ide.c static int platform_ide_probe(struct device_d *dev) · line 175
Quoted 10 lines
drivers/ata/intf_platform_ide.c +4
-0+ } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Am Freitag, den 04.09.2015, 12:40 +0300 schrieb Peter Mamonov:
Quoted 7 lines
Hi, Lucas!
Quoted 2 lines · On Thu, 03 Sep 2015 17:46:32 +0200 Lucas Stach <[email protected]> wrote:
Hi Peter.
Quoted 8 lines
Quoted 3 lines
Sorry, but this patch is wrong. You can't just make up completely ad-hoc DT bindings. You are pushing platformdata 1:1 into the DT, which is not how the conversion to DT should be done.
Could you clarify your point? My current understanding is that drivers instantiation from a platform code and from a DT are equal approaches, which should mirror each other.
No not at all. DT bindings are API between the DT and barebox/Linux, so they can not in all cases mirror platformdata, which we are able to change at will.
DT instantiation need a well thought through binding, which isn't some ad-hoc mirroring of the current platformdata.
Normally the binding is established by writing it down in the Linux kernel Documentation/devicetree/bindings folder (and obviously getting it through the DT review process).
Quoted 4 lines
Quoted 4 lines
There is also no pre-existing binding for "ata-generic" in the Linux kernel which would define any of those properties.
Quoted 8 lines
Quoted 4 lines
Most likely your IDE controller is inside some SoC specific block, with a specific compatible, which may also handle clocks and other required stuff and that one should instantiate the IDE driver if needed.
I've got your point. However,
drivers/ata/pata_of_platform.cfrom Linux also lacks any clock/stuff initialization.
If there is already a Linux driver with this binding you can reuse that one, as it's already established, even if there is no proper documentation there. If the binding is enough for your use-case that's okay.
You can however not make any ad-hoc additions to the established bindings, so if it doesn't fit your needs you need to propose the addition to the generic binding to DT reviewers, or think about a SoC specific binding if you need clocks/regulators or other things that don't belong in a generic binding.
Regards,
Lucas
Quoted 86 lines
Regards,
PeterQuoted 81 lines
Regards,
LucasAm Donnerstag, den 03.09.2015, 16:38 +0300 schrieb Peter Mamonov:
Quoted 75 lines
Signed-off-by Peter Mamonov <[email protected]>--- drivers/ata/intf_platform_ide.c | 35+++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
(quoted diff) +0
-0
b/drivers/ata/intf_platform_ide.cindex 0d392d8..f20e0e0 100644drivers/ata/intf_platform_ide.c +16
-2@@ -29,6 +29,7 @@#include <ata_drive.h> #include <platform_ide.h> #include <linux/err.h> +#include <of.h> /** * Setup the register specific addresses for an ATA like divice @@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev) void *reg_base, *alt_base = NULL;struct resource *reg, *alt;int mmio =0 ; +struct device_node *dn = dev->device_node; +u32 tmp32;if (pdata ==NULL ) { -dev_err (dev,"No platform data. Cannot continue\n"); -return -EINVAL ; + /* try to get platform data from the device tree */ + if (dn == NULL) { +dev_err (dev,"No platform data. Cannot continue\n"); +return -EINVAL ; + } + + pdata =xzalloc (sizeof (struct ide_port_info )); + +if (!pdata) { +dev_err (dev,"Platform data allocation failed\n"); +return -ENOMEM ; + } + device_add_data(dev, pdata, sizeof(struct
ide_port_info)); +drivers/ata/intf_platform_ide.c +4
-0+if (of_property_read_bool (dn,"dataif-be" )) + pdata->dataif_be =1 ; + + if (of_property_read_u32(dn, "reg-shift", &tmp32)== 0)
drivers/ata/intf_platform_ide.c +12
-0+ pdata->ioport_shift = (unsigned )tmp32; + + dev->platform_data = pdata; } reg_base =dev_request_mem_region (dev,0 );@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev) return rc; } +static __maybe_unused struct of_device_id platform_ide_dt_ids[] = { + { + .compatible ="ata-generic" , + }, { +/* sentinel */ + } +}; +static struct driver_d platform_ide_driver = { .name ="ide_intf" , .probe = platform_ide_probe, + .of_compatible =DRV_OF_COMPAT (platform_ide_dt_ids), };device_platform_driver (platform_ide_driver);
Signature · 8 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox