diff options
author | Alessandro Rubini <rubini@gnudd.com> | 2014-02-22 03:11:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-28 18:12:08 -0500 |
commit | 5c9a87367daf292244bd9bb3e67516dfa0027516 (patch) | |
tree | c62996f9f46349aa3dfb86330ae7ec45ae2e0ad9 /Documentation/fmc/fmc-write-eeprom.txt | |
parent | dd97b2410e70d881a362e5b31b702f59c21e0da6 (diff) |
FMC: make eeprom attribute writable
This allows easier modification to the eeprom than loading the
fmc-write-eeprom module. The carrier driver will refuse writing if
the FPGA is not running the golden gateware image, so writing in
practice is only available at manufacture/development time.
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Acked-by: Juan David Gonzalez Cobas <dcobas@cern.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/fmc/fmc-write-eeprom.txt')
-rw-r--r-- | Documentation/fmc/fmc-write-eeprom.txt | 77 |
1 files changed, 25 insertions, 52 deletions
diff --git a/Documentation/fmc/fmc-write-eeprom.txt b/Documentation/fmc/fmc-write-eeprom.txt index 44a3bc678bf0..e0a9712156aa 100644 --- a/Documentation/fmc/fmc-write-eeprom.txt +++ b/Documentation/fmc/fmc-write-eeprom.txt | |||
@@ -9,7 +9,12 @@ Overwriting the EEPROM is not something you should do daily, and it is | |||
9 | expected to only happen during manufacturing. For this reason, the | 9 | expected to only happen during manufacturing. For this reason, the |
10 | module makes it unlikely for the random user to change a working EEPROM. | 10 | module makes it unlikely for the random user to change a working EEPROM. |
11 | 11 | ||
12 | The module takes the following measures: | 12 | However, since the EEPROM may include application-specific information |
13 | other than the identification, later versions of this packages added | ||
14 | write-support through sysfs. See *note Accessing the EEPROM::. | ||
15 | |||
16 | To avoid damaging the EEPROM content, the module takes the following | ||
17 | measures: | ||
13 | 18 | ||
14 | * It accepts a `file=' argument (within /lib/firmware) and if no | 19 | * It accepts a `file=' argument (within /lib/firmware) and if no |
15 | such argument is received, it doesn't write anything to EEPROM | 20 | such argument is received, it doesn't write anything to EEPROM |
@@ -70,56 +75,24 @@ first time. | |||
70 | [ 132.899872] fake-fmc: Product name: FmcDelay1ns4cha | 75 | [ 132.899872] fake-fmc: Product name: FmcDelay1ns4cha |
71 | 76 | ||
72 | 77 | ||
73 | Writing to the EEPROM | 78 | Accessing the EEPROM |
74 | ===================== | 79 | ===================== |
75 | 80 | ||
76 | Once you have created a binary file for your EEPROM, you can write it | 81 | The bus creates a sysfs binary file called eeprom for each mezzanine it |
77 | to the storage medium using the fmc-write-eeprom (See *note | 82 | knows about: |
78 | fmc-write-eeprom::, while relying on a carrier driver. The procedure | 83 | |
79 | here shown here uses the SPEC driver | 84 | spusa.root# cd /sys/bus/fmc/devices; ls -l */eeprom |
80 | (`http://www.ohwr.org/projects/spec-sw'). | 85 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcAdc100m14b4cha-0800/eeprom |
81 | 86 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDelay1ns4cha-0200/eeprom | |
82 | The example assumes no driver is already loaded (actually, I unloaded | 87 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDio5cha-0400/eeprom |
83 | them by hand as everything loads automatically at boot time after you | 88 | |
84 | installed the modules), and shows kernel messages together with | 89 | Everybody can read the files and the superuser can also modify it, but |
85 | commands. Here the prompt is spusa.root# and two SPEC cards are plugged | 90 | the operation may on the carrier driver, if the carrier is unable to |
86 | in the system. | 91 | access the I2C bus. For example, the spec driver can access the bus |
87 | 92 | only with its golden gateware: after a mezzanine driver reprogrammed | |
88 | spusa.root# insmod fmc.ko | 93 | the FPGA with a custom circuit, the carrier is unable to access the |
89 | spusa.root# insmod spec.ko | 94 | EEPROM and returns ENOTSUPP. |
90 | [13972.382818] spec 0000:02:00.0: probe for device 0002:0000 | 95 | |
91 | [13972.392773] spec 0000:02:00.0: got file "fmc/spec-init.bin", 1484404 (0x16a674) bytes | 96 | An alternative way to write the EEPROM is the mezzanine driver |
92 | [13972.591388] spec 0000:02:00.0: FPGA programming successful | 97 | fmc-write-eeprom (See *note fmc-write-eeprom::), but the procedure is |
93 | [13972.883011] spec 0000:02:00.0: EEPROM has no FRU information | 98 | more complex. |
94 | [13972.888719] spec 0000:02:00.0: No device_id filled, using index | ||
95 | [13972.894676] spec 0000:02:00.0: No mezzanine_name found | ||
96 | [13972.899863] /home/rubini/wip/spec-sw/kernel/spec-gpio.c - spec_gpio_init | ||
97 | [13972.906578] spec 0000:04:00.0: probe for device 0004:0000 | ||
98 | [13972.916509] spec 0000:04:00.0: got file "fmc/spec-init.bin", 1484404 (0x16a674) bytes | ||
99 | [13973.115096] spec 0000:04:00.0: FPGA programming successful | ||
100 | [13973.401798] spec 0000:04:00.0: EEPROM has no FRU information | ||
101 | [13973.407474] spec 0000:04:00.0: No device_id filled, using index | ||
102 | [13973.413417] spec 0000:04:00.0: No mezzanine_name found | ||
103 | [13973.418600] /home/rubini/wip/spec-sw/kernel/spec-gpio.c - spec_gpio_init | ||
104 | spusa.root# ls /sys/bus/fmc/devices | ||
105 | fmc-0000 fmc-0001 | ||
106 | spusa.root# insmod fmc-write-eeprom.ko busid=0x0200 file=fdelay-eeprom.bin | ||
107 | [14103.966259] spec 0000:02:00.0: Matching an generic driver (no ID) | ||
108 | [14103.975519] spec 0000:02:00.0: programming 6155 bytes | ||
109 | [14126.373762] spec 0000:02:00.0: write_eeprom: success | ||
110 | [14126.378770] spec 0000:04:00.0: Matching an generic driver (no ID) | ||
111 | [14126.384903] spec 0000:04:00.0: fmc_write_eeprom: no filename given: not programming | ||
112 | [14126.392600] fmc_write_eeprom: probe of fmc-0001 failed with error -2 | ||
113 | |||
114 | Reading back the EEPROM | ||
115 | ======================= | ||
116 | |||
117 | In order to read back the binary content of the EEPROM of your | ||
118 | mezzanine device, the bus creates a read-only sysfs file called eeprom | ||
119 | for each mezzanine it knows about: | ||
120 | |||
121 | spusa.root# cd /sys/bus/fmc/devices; ls -l */eeprom | ||
122 | -r--r--r-- 1 root root 8192 Apr 9 16:53 FmcDelay1ns4cha-f001/eeprom | ||
123 | -r--r--r-- 1 root root 8192 Apr 9 17:19 fake-design-for-testing-f002/eeprom | ||
124 | -r--r--r-- 1 root root 8192 Apr 9 17:19 fake-design-for-testing-f003/eeprom | ||
125 | -r--r--r-- 1 root root 8192 Apr 9 17:19 fmc-f004/eeprom | ||