summaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/eeprom.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/lseek'Sascha Hauer2019-02-131-2/+0
|\
| * devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Fix debug print warningAndrey Smirnov2019-02-111-1/+2
|/ | | | | | | | Cast eeprom->word_size to int, so it would match its printf specifier to avoid getting errors when building on AArch64. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-12-071-2/+2
|\
| * net/e1000: Mark e1000_register_invm() staticAndrey Smirnov2018-11-191-1/+1
| | | | | | | | | | | | | | | | Mark e1000_register_invm() static because it is not used outside the source file. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net/e1000: Mark e1000_igb_get_flash_size() staticAndrey Smirnov2018-11-191-1/+1
| | | | | | | | | | | | | | | | Mark e1000_igb_get_flash_size() static because it is not used outside the source file. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | e1000/flash: Increased erase timeoutMichael Schuhmacher2018-11-121-1/+1
|/ | | | | | | | Serial flash Adesto AT25DF321A specifies the maximal chip erase time as 40 seconds. Extend timeout accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: allow to overwrite flash size from device treeUwe Kleine-König2018-07-131-14/+42
| | | | | | | | | | | | | | | | | When barebox probes the e1000 driver and the flash on the i210 device is unprogrammed, the driver assumes the flash has a size of only 4 kiB. This is annoying because to program the flash an image must be written that is bigger than 4 kiB. So you first have to flash the first sector to make barebox detect the right size on the next boot. Then reset the board to be able to write the remaining data. To work around that limitation, try to read the actual size from the device tree. (Note however that barebox' pci code currently doesn't use the device tree and so currently this try always fails without further patching.) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-2/+2
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't register EERPOM device if the content is invalidLucas Stach2018-01-301-17/+24
| | | | | | | | If the EEPROM content isn't valid, there is no point in registering the EEPROM device, as it will reject any read attempt anyway. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't check EEPROM signature if populated from iNVMLucas Stach2018-01-301-6/+4
| | | | | | | | | | The EEPROM device will contain an invalid signature if it has been populated from iNVM. Since the iNVM enum type has been removed, the only way to tell if a signature check makes sense is to look at the EEPROM valid status. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: EEPROM isn't valid if only iNVM is availableLucas Stach2018-01-301-8/+6
| | | | | | | | | | | | | There is no point in registering the emulated EEPROM device if only the iNVM is available with no external flash attached to the i210, as in practice it's only shadowing the iNVM. When the EEPROM is populated from iNVM, the signature is not valid, which causes other parts of the driver to fall over. To fix this just ignore the EEPROM in that case. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: remove one level of indentationLucas Stach2018-01-301-60/+61
| | | | | | | By returning early if the MAC type isn't e1000_igb. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix driver probing in the presence of two e1000 devicesUwe Kleine-König2018-01-171-0/+1
| | | | | | | | | | | | | | | | The .id member of the struct device for the invm device is not initialized and so implicitly zero. This yields: register_device: already registered invm0 for the second i210 during probe. So use the parent's id to initialize the id for invm, too, as is already done for the corresponding e1000-nor device. Fixes: a74b97f009c6 ("e1000: Expose i210's iNVM as a cdev") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: indicate at boot time if flash is in secure modeUwe Kleine-König2017-12-061-3/+7
| | | | | | | | If the flash is in secure mode it is not possible to modify its contents. So log that useful information at probe time. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: add missing \n in error messageUwe Kleine-König2017-12-011-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: implement protect and unprotect for attached flashUwe Kleine-König2017-11-281-0/+70
| | | | | | | | | | | | | Some supported flash devices (e.g. SST25VF040) are write protected after power up. If the device holds a valid firmware image the i210 can handle that just fine. If however there is no firmware programmed, a procedure is needed to remove this protection before an image can be flashed. So implement the needed callbacks to make the commands protect and unprotect do the right thing. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: expand timeout for flash erasureUwe Kleine-König2017-11-241-1/+1
| | | | | | | | | | | | | | Erasing the whole flash takes approximately 7s on one of my test machines. Expand the timeout accordingly. Note however that it is in general not allowed to hold the flash semaphore for so long and "firmware might implement a timeout mechanism and take ownership of the relevant [lock]" after one second. So a chip erase should better only be done when firmware doesn't make use of the flash. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: indicate in error messages where the failure occuredUwe Kleine-König2017-11-241-4/+4
| | | | | | | | | | | | There used to be four places that all emit the same error message. Even if in a given context not all four of them can be relevant, there are always two possible locations where the message can origin from. So make the output slightly different in all places to ease future debugging. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't access the (simulated) eeprom when it is invalidUwe Kleine-König2017-11-241-5/+31
| | | | | | | | | | The shadow RAM that is used to serve read requests from the eeprom interface isn't valid in all cases. Catch these by returning an error in the eeprom read function and make eeprom validation dependant on working access. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: log flash/invm status at probe timeUwe Kleine-König2017-11-241-0/+18
| | | | | | | Provide some info about flash/eeprom state at boot up Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: provide device for accessing emulated eepromUwe Kleine-König2017-11-241-1/+42
| | | | | | | | This device uses e1000_read_eeprom to provide access to the emulated eeprom on e1000-igb. Only reading is implemented for now. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix size of invm deviceUwe Kleine-König2017-11-241-1/+1
| | | | | | | The iNVM storage is 2 Kib containing 64 32bit words (0-63). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: provide access to iNVM even if a flash is presentUwe Kleine-König2017-11-241-62/+71
| | | | | | | | | | | | | | | | | | | An i210 (aka e1000_igb) supports two different non-volatile storages for configuration. There is a built-in one-time programmable storage called iNVM and an optional external SPI-Flash. If a flash is populated and contains a valid configuration image the iNVM is not used (if I understood the documentation correctly). Still the iNVM can be useful if the flash is not configured. Also the iNVM contains manufacturing identification information. So it makes sense to provide the invm device even if a flash is present. This patch also cleans up some confusion that suggests that invm is a way to access the (simulated) eeprom structures and drops some unused enum values. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: reorder functionsUwe Kleine-König2017-11-241-70/+67
| | | | | | | | Bring functions in a more natural order which allows to drop a few forward declarations. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix coding style at a few locationsUwe Kleine-König2017-11-241-3/+12
| | | | | | | | While working on the e1000 driver I noticed a few coding style misdeeds. These are fixed here. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transactionUwe Kleine-König2017-10-161-11/+2
| | | | | | | | | While FLSWCTL.GLDONE is set when the last transaction was fully completed, there is no good reason to depend on this. According to the i210 datasheet having FLSWCTL.DONE is enough. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: implement support for smaller flash chipsUwe Kleine-König2017-10-161-11/+3
| | | | | | | | | | | | | | | Even though the register description of the FLA register suggests (on page 386 of the i210 datasheet (rev. 3.1)) that 2 MB, 4 MB and 8 MB are the only supported flash sizes, the list of supported flashes (on page 794 of the same document) lists for example a Micron M25PE80 which only has a size of 1 MB. Also in general it seems sensible to stick to the formula given for the meaning of the values that are not explicitly listed. Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Expose i210's external flash as MTDAndrey Smirnov2016-06-031-2/+386
| | | | | | | | Add code needed to access SPI-NOR flash attached to i210 as a regular MTD device. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Expose i210's iNVM as a cdevAndrey Smirnov2016-06-031-0/+312
| | | | | | | | | Add code needed to expose iNVM memory on the chip as a cdev. The driver also registers a dummy "invm" device that exposes "locked" property which is used to implement iNMV line locking feature. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Add EEPROM access locking for i210Andrey Smirnov2016-06-031-1/+18
| | | | | | | | | As per datasheet (section 4.6 p. 147) accessing EEPROM on i210 requires software to hold a corresponding lock bit in SW_FW_SYNC register. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Refactor Flash/EEPROM reading codeAndrey Smirnov2016-06-031-125/+187
| | | | | | | | | | Refactor Flash/EEPROM reading code to use vtable with pointers to small, specialized functions based on the flash class instead of big monolithic funtions whose behaviour is driven by a number of flags and variables. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Remove unnecessary intializationAndrey Smirnov2016-06-031-4/+0
| | | | | | | | We always call e1000_init_eeprom_params() as a part of probing, so there's no need check if it needs to be called in e1000_read_eeprom(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Fix a bug in e1000_probe()Andrey Smirnov2016-06-031-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several reasons why that code in e1000_probe had to be changed: - It reads from chip variant specific register (present only on i210) in a chip variant agnostic codepath - It makes no sense to check for FLUPD bit to make a decision weither to validate EEPROM or not since its function per datasheet is: " ... Flash Update. Writing 1b to this bit causes the content of the internal 4 KB shadow RAM to be written into one of the first two 4 KB sectors of the Flash device (Sector 0 or Sector 1). The bit is self-cleared immediately... " and it is only through sheer serendipity the defined value for bitmask for FLUPD is equivalent to bitmask for FLASH_DETECTED bit which is the bit we actually care about and need to test against (FLUPD for i210 has a different bitmask) Fix those problems by replacing the i210 specific check inside of e1000_validate_eeprom_checksum() with a chip agnostic one and using correct bitmask. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Consolidate Microwire EEPROM init codeAndrey Smirnov2016-06-031-31/+21
| | | | | | | | | All of the chips that bitbang Microwire to access EEPROM appear to be configured in the same way, so move common code into a separate function and make use of it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Consolidate SPI EEPROM init codeAndrey Smirnov2016-06-031-25/+21
| | | | | | | | | All of the chips that bitbang SPI to access EEPROM appear to be configured in the same way, so move common code into a separate function and make use of it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Simplify EEPROM init for e1000_igbAndrey Smirnov2016-06-031-3/+0
| | | | | | | | | That chip specifies read access uising EERD via use_eerd, which means that none of the more "advanced" EEPROM parameters will be used for reads, so remove them. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Simplify EEPROM init for e1000_80003es2lanAndrey Smirnov2016-06-031-7/+0
| | | | | | | | | That chip specifies read access uising EERD via use_eerd, which means that none of the more "advanced" EEPROM parameters will be used for reads, so remove them. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Remove 'page_size'Andrey Smirnov2016-06-031-21/+11
| | | | | | | | Remove 'page_size' from 'struct e1000_eeprom_info' since it is not used anywhere in the code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Remove 'use_eewr' parameterAndrey Smirnov2016-06-031-7/+0
| | | | | | | | Remove 'use_eewr' from 'struct e1000_eeprom_info' since it is not used anywhere in the code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Consolidate register offset fixupsAndrey Smirnov2016-06-031-7/+3
| | | | | | | | | | | | | | | | | | Consolidate all code taking care on CSR offset differences for i210 chips into a single place in the driver and integrate that funcionality into e1000_{read,write}_reg functions. This way we can get rid of all those if (hw->mac_type == e1000_igb) { .... } else { .... } snippets sprinkled all across the driver code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Remove unneeded i210 specific register codeAndrey Smirnov2016-06-031-20/+5
| | | | | | | | | Despite having EEC(EECD) and EERD at "non-standard" offsets i210 aliases those registers to be accesible via regular addresses so none of the code removed by this commit is really necessary. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Convert E1000_*_REG macros to functionsAndrey Smirnov2016-06-031-51/+51
| | | | | | | | | E1000_*_REG don't bring any value by being macros and implicit appending of "E1000_" prefix to the constant name only makes thing harder to grep or understand. Replace those macros with functions. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Include <net.h> in e1000.hAndrey Smirnov2016-06-031-1/+0
| | | | | | | | | That header(e1000.h) uses a number of definitions from net.h, so for it to be self-contained it needs to include that file. This change also allows remove includes of net.h from other files. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Split driver into multiple filesAndrey Smirnov2016-06-031-0/+747
The driver has a number of not very tightly coupled subsystems and at 4K+ lines e1000.c is getting rather hard to wrangle, so let's move EEPROM handling code (very self contained susbsystem) into a separate file and put all of the driver into a dedicated subdirectory. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>