diff options
Diffstat (limited to 'arch/arm/mach-imx/iim.c')
-rw-r--r-- | arch/arm/mach-imx/iim.c | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c index 207e1879c3..f4581396b1 100644 --- a/arch/arm/mach-imx/iim.c +++ b/arch/arm/mach-imx/iim.c @@ -1,19 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: 2010 Baruch Siach <baruch@tkos.co.il>, Orex Computed Radiography + /* * iim.c - i.MX IIM fusebox driver * * Provide an interface for programming and sensing the information that are * stored in on-chip fuse elements. This functionality is part of the IC * Identification Module (IIM), which is present on some i.MX CPUs. - * - * Copyright (c) 2010 Baruch Siach <baruch@tkos.co.il>, - * Orex Computed Radiography - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html */ #include <common.h> @@ -26,15 +19,16 @@ #include <malloc.h> #include <of.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> #include <linux/err.h> +#include <machine_id.h> -#include <mach/iim.h> -#include <mach/imx51-regs.h> -#include <mach/imx53-regs.h> -#include <mach/clock-imx51_53.h> -#include <mach/imx25-fusemap.h> +#include <mach/imx/iim.h> +#include <mach/imx/imx51-regs.h> +#include <mach/imx/imx53-regs.h> +#include <mach/imx/clock-imx51_53.h> +#include <mach/imx/imx25-fusemap.h> #define DRIVERNAME "imx_iim" #define IIM_NUM_BANKS 8 @@ -50,7 +44,7 @@ struct iim_bank { }; struct iim_priv { - struct device_d dev; + struct device dev; void __iomem *base; void __iomem *bankbase; struct iim_bank *bank[IIM_NUM_BANKS]; @@ -298,7 +292,7 @@ err_out: return ret; } -static ssize_t imx_iim_reg_write(void *ctx, unsigned int reg, unsigned int val) +static int imx_iim_reg_write(void *ctx, unsigned int reg, unsigned int val) { struct iim_bank *bank = ctx; @@ -329,10 +323,10 @@ static int imx_iim_add_bank(struct iim_priv *iim, int num, int nregs) iim->bank[num] = bank; - bank->map_config.reg_bits = 8, - bank->map_config.val_bits = 8, - bank->map_config.reg_stride = 1, - bank->map_config.max_register = (nregs - 1), + bank->map_config.reg_bits = 8; + bank->map_config.val_bits = 8; + bank->map_config.reg_stride = 1; + bank->map_config.max_register = (nregs - 1); bank->map_config.name = xasprintf("bank%d", num); bank->map = regmap_init(&iim->dev, &imx_iim_regmap_bus, bank, &bank->map_config); @@ -411,11 +405,11 @@ static void imx_iim_add_mac_param(struct iim_priv *iim, int macnum, int bank, in */ #define MAC_ADDRESS_PROPLEN (3 * sizeof(__be32)) -static void imx_iim_init_dt(struct device_d *dev, struct iim_priv *iim) +static void imx_iim_init_dt(struct device *dev, struct iim_priv *iim) { char mac[6]; const __be32 *prop; - struct device_node *node = dev->device_node; + struct device_node *node = dev->of_node; int len, ret, macnum = 0; if (!node) @@ -449,12 +443,12 @@ static void imx_iim_init_dt(struct device_d *dev, struct iim_priv *iim) } } #else -static inline void imx_iim_init_dt(struct device_d *dev, struct iim_priv *iim) +static inline void imx_iim_init_dt(struct device *dev, struct iim_priv *iim) { } #endif -static int imx_iim_probe(struct device_d *dev) +static int imx_iim_probe(struct device *dev) { struct resource *iores; struct iim_priv *iim; @@ -511,6 +505,25 @@ static int imx_iim_probe(struct device_d *dev) dev_add_param_bool(&iim->dev, "explicit_sense_enable", NULL, NULL, &iim->sense_enable, NULL); + /* Maybe this is too strict? This might also work on i.MX31 and i.MX35 */ + if (IS_ENABLED(CONFIG_MACHINE_ID) && + of_device_is_compatible(dev->of_node, "fsl,imx25-iim")) { + char uid[8]; + + for (i = 0; i < 8; ++i) { + unsigned int value; + + ret = imx_iim_read_field(IMX25_IIM_UID(i), &value); + if (ret) + break; + + uid[i] = value; + } + + if (!ret) + machine_id_set_hashable(uid, 8); + } + return 0; } @@ -579,17 +592,12 @@ static __maybe_unused struct of_device_id imx_iim_dt_ids[] = { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, imx_iim_dt_ids); -static struct driver_d imx_iim_driver = { +static struct driver imx_iim_driver = { .name = DRIVERNAME, .probe = imx_iim_probe, .of_compatible = DRV_OF_COMPAT(imx_iim_dt_ids), }; -static int imx_iim_init(void) -{ - platform_driver_register(&imx_iim_driver); - - return 0; -} -coredevice_initcall(imx_iim_init); +coredevice_platform_driver(imx_iim_driver); |