summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/ocotp.c
Commit message (Collapse)AuthorAgeFilesLines
* i.MX: ocotp: Add imx_ocotp_sense_enable()Andrey Smirnov2017-01-121-0/+7
| | | | | | | | Add imx_ocotp_sense_enable() function to allow changing that aspect of OCOTP driver behaviour before calling imx_ocotp_read_field() Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Initialize OCOTP as early as possibleAndrey Smirnov2017-01-121-1/+1
| | | | | | | | | On Vybrid SoC OCOTP module contains speed grading information that is needed to correctly adjust CPU clock to its maxumum rate, so we need to have this information handy as early as possible. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Add provisions for storing multiple MAC addressesAndrey Smirnov2017-01-121-19/+51
| | | | | | | | | | | | i.MX SoC variants like Vybrid have more than one built-in Ethernet interface and as a consequence support storing more than one MAC address in OCOTP module. Add code to create multiple 'mac_addr<n>' parameters as well as 'mac_addr' as an "alias" to 'mac_addr0' for backwards compatibility. Acked-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Move memory reversing into a subroutineAndrey Smirnov2017-01-121-7/+13
| | | | | | | | Move memory reversing, found in imx_ocotp_get_mac and imx_ocotp_set_mac, into a subroutine to avoid code duplication. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Add Vybrid supportAndrey Smirnov2017-01-111-0/+16
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Account for shadow memory gapsAndrey Smirnov2017-01-111-3/+31
| | | | | | | | | | Shadow memory does not have a true 1:1 mapping to fuse address space. All i.MX6 devices, with exception of i.MX6SL have a 0x100 byte gap between banks 5 and 6 (or addresses 0x2f and 0x30), so we need to account for that when reading data from shadow memory. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Remove unused #defineAndrey Smirnov2017-01-111-1/+0
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: Add i.MX6ul supportSascha Hauer2016-11-081-0/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: OCOTP: Add functions to access fuses field wiseSascha Hauer2016-11-081-0/+65
| | | | | | | Add functions to access the OCOTP fuses field wise, similar to what has been done for the IIM. Also add a i.MX6 fusemap header file. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: ocotp: Register regmap against orignal deviceAndrey Smirnov2016-07-191-1/+1
| | | | | | | | | Register regmap against orignal device passed to probe, this way further in the code/call-chain cdev's device_node will be correctly populated and it will be discoverable via cdev_by_device_node() Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: Switch to regmap supportSascha Hauer2016-02-051-89/+56
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: Fix error bit handlingSascha Hauer2016-02-051-13/+10
| | | | | | | | | Instead of returning an error when a locked region is read, fill the result with 0xbadabada to indicate a locked region is read. This way a md -s /dev/imx-ocotp does not abort when it encounters locked regions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: make priv the first argument of functionsSascha Hauer2016-02-051-16/+16
| | | | | | | Throughout our codebase the private context pointer is the first argument to a function. Do this for the ocotp driver aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: Explicitly access control registerSascha Hauer2016-02-051-7/+8
| | | | | | | | Even when the control register has offset 0x0 it's still nice to use a register define for it. Accessing priv->base directly just looks wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: ocotp: Fix fusebox sizeSascha Hauer2016-02-051-1/+23
| | | | | | | All i.MX6 SoCs except the i.MX6SL have 4kbit fuses. The i.MX6SL has 2kbit fuses. Fix the device size accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: When creating a new cdev, initialize device_nodeTrent Piepho2016-01-081-1/+0
| | | | | | | | | | | | | | | If a new cdev doesn't have a device_node defined when passed to devfs_create(), set it to the device_node of the parent device, if one exists. For non-partitions, like ocotp or eeprom devices, this is the correct thing to do. Partitions need to use, and do use, a different node. The code from commit 274e0b8dc48956babeaa2faf70bf8066e656b621 to set device_node in ocotp can be removed. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imx: ocotp: Add code to initialize 'cdev->device_node'Andrey Smirnov2015-12-071-0/+1
| | | | | | | | | In order for cdev_by_device_node() to be able to return approprate character device for <&ocotp> phandle cdev->device_node needs to be initialized with dev->device_node. This patche takes care of that Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX6: ocotp: remove useless codeSascha Hauer2015-03-201-2/+0
| | | | | | | cdev->name is initialized to a static string, so no need to check if it's non NULL. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx'Sascha Hauer2014-12-081-9/+22
|\
| * ARM: i.MX: ocotp: Add i.MX6sx compatible entrySascha Hauer2014-11-271-0/+2
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: i.MX: ocotp: Fix MAC address provider for unaligned addressesSascha Hauer2014-11-271-9/+20
| | | | | | | | | | | | | | | | | | | | The current algorithm assumes the MAC address starts at a 4 byte aligned address. Unfortunately this is not always the case. On the i.MX6sx the MAC Address for the second FEC starts at offset 0x632. The register space for the fuse map has holes, only the 16 byte aligned words contain data. This means we have to skip the holes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | arm: imx: iim/ocotp: fix link error when !CONFIG_NETLucas Stach2014-11-271-2/+4
|/ | | | | | | | | Don't try to attach mac to device if there is no net support selected. Fixes: undefined reference to `dev_add_param_mac' in both iim and ocotp drivers. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+2
| | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imx6: ocotp: Add On-Chip OTP registers write supportUladzimir Bely2014-05-051-0/+356
| | | | | | | | | | | | | | | | | | | | | | | | | | FUSEs (OTP registers) can be written via /dev/imx-ocotp character device. For example, writing MAC 12:34:56:78:9A:BC can be performed as > mw -l -d /dev/imx-ocotp 0x8c 0x00001234 > mw -l -d /dev/imx-ocotp 0x88 0x56789ABC and reading as > md -l -s /dev/imx-ocotp 0x88+8 00000088: 56789ABC 00001234 , where 0x88 (0x22*4) and 0x8C (0x23*4) are offsets of MAC OTP registers. Notice: FUSEs are PROM, so "0" (unprogrammed) bits can be replaced with "1" (but not vice versa) only once. Also, for MAC there are convinient parameters: > ocotp0.permanent_write_enable=1 > ocotp0.mac_addr=12:34:56:78:9A:BC imx_ocotp 21bc000.ocotp: reloading shadow registers... imx_ocotp 21bc000.ocotp: reloading shadow registers... > echo $ocotp0.mac_addr 12:34:56:78:9A:BC Signed-off-by: Uladzimir Bely <u.bely@sam-solutions.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-081-0/+1
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX6: Add ocotp driverSascha Hauer2013-07-221-0/+105
The only functionality at the moment is to register a MAC Address for an ethernet device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>