From cd0f34b08f98af72bb2f74fe4bd251558fc734d3 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 12 Jul 2012 09:57:52 +0000 Subject: mfd: mc13xxx: Change probing details for mc13xxx devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes auto-detection of which variant of mc13xxx is used because mc34708 uses a different layout in the revision register that doesn't allow differentiation any more. Signed-off-by: Uwe Kleine-König Acked-by: Marc Reilly Signed-off-by: Samuel Ortiz --- drivers/mfd/mc13xxx-spi.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'drivers/mfd/mc13xxx-spi.c') diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 0bdb43a0aff0..9b1e60827f37 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c @@ -28,10 +28,10 @@ static const struct spi_device_id mc13xxx_device_id[] = { { .name = "mc13783", - .driver_data = MC13XXX_ID_MC13783, + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13783, }, { .name = "mc13892", - .driver_data = MC13XXX_ID_MC13892, + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892, }, { /* sentinel */ } @@ -39,8 +39,8 @@ static const struct spi_device_id mc13xxx_device_id[] = { MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); static const struct of_device_id mc13xxx_dt_ids[] = { - { .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, }, - { .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, }, + { .compatible = "fsl,mc13783", .data = &mc13xxx_variant_mc13783, }, + { .compatible = "fsl,mc13892", .data = &mc13xxx_variant_mc13892, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids); @@ -144,19 +144,18 @@ static int mc13xxx_spi_probe(struct spi_device *spi) return ret; } - ret = mc13xxx_common_init(mc13xxx, pdata, spi->irq); + if (spi->dev.of_node) { + const struct of_device_id *of_id = + of_match_device(mc13xxx_dt_ids, &spi->dev); - if (ret) { - dev_set_drvdata(&spi->dev, NULL); + mc13xxx->variant = of_id->data; } else { - const struct spi_device_id *devid = - spi_get_device_id(spi); - if (!devid || devid->driver_data != mc13xxx->ictype) - dev_warn(mc13xxx->dev, - "device id doesn't match auto detection!\n"); + const struct spi_device_id *id_entry = spi_get_device_id(spi); + + mc13xxx->variant = (void *)id_entry->driver_data; } - return ret; + return mc13xxx_common_init(mc13xxx, pdata, spi->irq); } static int __devexit mc13xxx_spi_remove(struct spi_device *spi) -- cgit v1.2.3 From 0312e024d6cde5ef02900c4c6e2f5bb982e24af5 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 12 Jul 2012 09:57:53 +0000 Subject: mfd: mc13xxx: Add support for mc34708 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Acked-by: Marc Reilly Signed-off-by: Samuel Ortiz --- drivers/mfd/mc13xxx-core.c | 21 +++++++++++++++++++++ drivers/mfd/mc13xxx-i2c.c | 6 ++++++ drivers/mfd/mc13xxx-spi.c | 4 ++++ drivers/mfd/mc13xxx.h | 3 ++- 4 files changed, 33 insertions(+), 1 deletion(-) (limited to 'drivers/mfd/mc13xxx-spi.c') diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index 40afdb9b73f5..2a9b100c4825 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c @@ -119,6 +119,11 @@ #define MC13XXX_REVISION_FAB (0x03 << 11) #define MC13XXX_REVISION_ICIDCODE (0x3f << 13) +#define MC34708_REVISION_REVMETAL (0x07 << 0) +#define MC34708_REVISION_REVFULL (0x07 << 3) +#define MC34708_REVISION_FIN (0x07 << 6) +#define MC34708_REVISION_FAB (0x07 << 9) + #define MC13XXX_ADC1 44 #define MC13XXX_ADC1_ADEN (1 << 0) #define MC13XXX_ADC1_RAND (1 << 1) @@ -424,6 +429,16 @@ static void mc13xxx_print_revision(struct mc13xxx *mc13xxx, u32 revision) maskval(revision, MC13XXX_REVISION_ICIDCODE)); } +static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision) +{ + dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n", + mc13xxx->variant->name, + maskval(revision, MC34708_REVISION_REVFULL), + maskval(revision, MC34708_REVISION_REVMETAL), + maskval(revision, MC34708_REVISION_FIN), + maskval(revision, MC34708_REVISION_FAB)); +} + /* These are only exported for mc13xxx-i2c and mc13xxx-spi */ struct mc13xxx_variant mc13xxx_variant_mc13783 = { .name = "mc13783", @@ -437,6 +452,12 @@ struct mc13xxx_variant mc13xxx_variant_mc13892 = { }; EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892); +struct mc13xxx_variant mc13xxx_variant_mc34708 = { + .name = "mc34708", + .print_revision = mc34708_print_revision, +}; +EXPORT_SYMBOL_GPL(mc13xxx_variant_mc34708); + static const char *mc13xxx_get_chipname(struct mc13xxx *mc13xxx) { return mc13xxx->variant->name; diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c index 4a0afc7f2d4e..bfc1284537ea 100644 --- a/drivers/mfd/mc13xxx-i2c.c +++ b/drivers/mfd/mc13xxx-i2c.c @@ -25,6 +25,9 @@ static const struct i2c_device_id mc13xxx_i2c_device_id[] = { { .name = "mc13892", .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892, + }, { + .name = "mc34708", + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc34708, }, { /* sentinel */ } @@ -35,6 +38,9 @@ static const struct of_device_id mc13xxx_dt_ids[] = { { .compatible = "fsl,mc13892", .data = &mc13xxx_variant_mc13892, + }, { + .compatible = "fsl,mc34708", + .data = &mc13xxx_variant_mc34708, }, { /* sentinel */ } diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 9b1e60827f37..afca4f92f0cf 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c @@ -32,6 +32,9 @@ static const struct spi_device_id mc13xxx_device_id[] = { }, { .name = "mc13892", .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892, + }, { + .name = "mc34708", + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc34708, }, { /* sentinel */ } @@ -41,6 +44,7 @@ MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); static const struct of_device_id mc13xxx_dt_ids[] = { { .compatible = "fsl,mc13783", .data = &mc13xxx_variant_mc13783, }, { .compatible = "fsl,mc13892", .data = &mc13xxx_variant_mc13892, }, + { .compatible = "fsl,mc34708", .data = &mc13xxx_variant_mc34708, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids); diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h index 78bf4c3c1fac..460ec5c7b18c 100644 --- a/drivers/mfd/mc13xxx.h +++ b/drivers/mfd/mc13xxx.h @@ -24,7 +24,8 @@ struct mc13xxx_variant { extern struct mc13xxx_variant mc13xxx_variant_mc13783, - mc13xxx_variant_mc13892; + mc13xxx_variant_mc13892, + mc13xxx_variant_mc34708; struct mc13xxx { struct regmap *regmap; -- cgit v1.2.3