Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv: Add interfaces for flash device access

This change adds the OPAL interface definitions to allow Linux to read,
write and erase from system flash devices. We register platform devices
for the flash devices exported by firmware.

We clash with the existing opal_flash_init function, which is really for
the FSP flash update functionality, so we rename that initcall to
opal_flash_update_init().

A future change will add an mtd driver that uses this interface.

Changes from Joel Stanley and Jeremy Kerr.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Cyril Bur and committed by
Michael Ellerman
ed59190e d1d91578

+31 -4
+4 -1
arch/powerpc/include/asm/opal-api.h
··· 150 150 #define OPAL_IPMI_SEND 107 151 151 #define OPAL_IPMI_RECV 108 152 152 #define OPAL_I2C_REQUEST 109 153 - #define OPAL_LAST 109 153 + #define OPAL_FLASH_READ 110 154 + #define OPAL_FLASH_WRITE 111 155 + #define OPAL_FLASH_ERASE 112 156 + #define OPAL_LAST 112 154 157 155 158 /* Device tree flags */ 156 159
+8 -1
arch/powerpc/include/asm/opal.h
··· 194 194 int64_t opal_i2c_request(uint64_t async_token, uint32_t bus_id, 195 195 struct opal_i2c_request *oreq); 196 196 197 + int64_t opal_flash_read(uint64_t id, uint64_t offset, uint64_t buf, 198 + uint64_t size, uint64_t token); 199 + int64_t opal_flash_write(uint64_t id, uint64_t offset, uint64_t buf, 200 + uint64_t size, uint64_t token); 201 + int64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size, 202 + uint64_t token); 203 + 197 204 /* Internal functions */ 198 205 extern int early_init_dt_scan_opal(unsigned long node, const char *uname, 199 206 int depth, void *data); ··· 233 226 struct rtc_time; 234 227 extern unsigned long opal_get_boot_time(void); 235 228 extern void opal_nvram_init(void); 236 - extern void opal_flash_init(void); 229 + extern void opal_flash_update_init(void); 237 230 extern void opal_flash_term_callback(void); 238 231 extern int opal_elog_init(void); 239 232 extern void opal_platform_dump_init(void);
+1 -1
arch/powerpc/platforms/powernv/opal-flash.c
··· 546 546 .attrs = image_op_attrs, 547 547 }; 548 548 549 - void __init opal_flash_init(void) 549 + void __init opal_flash_update_init(void) 550 550 { 551 551 int ret; 552 552
+3
arch/powerpc/platforms/powernv/opal-wrappers.S
··· 292 292 OPAL_CALL(opal_ipmi_send, OPAL_IPMI_SEND); 293 293 OPAL_CALL(opal_ipmi_recv, OPAL_IPMI_RECV); 294 294 OPAL_CALL(opal_i2c_request, OPAL_I2C_REQUEST); 295 + OPAL_CALL(opal_flash_read, OPAL_FLASH_READ); 296 + OPAL_CALL(opal_flash_write, OPAL_FLASH_WRITE); 297 + OPAL_CALL(opal_flash_erase, OPAL_FLASH_ERASE);
+15 -1
arch/powerpc/platforms/powernv/opal.c
··· 693 693 "rc = %d\n", rc); 694 694 } 695 695 696 + static void opal_flash_init(struct device_node *opal_node) 697 + { 698 + struct device_node *np; 699 + 700 + for_each_child_of_node(opal_node, np) 701 + if (of_device_is_compatible(np, "ibm,opal-flash")) 702 + of_platform_device_create(np, NULL, NULL); 703 + } 704 + 696 705 static void opal_ipmi_init(struct device_node *opal_node) 697 706 { 698 707 struct device_node *np; ··· 826 817 /* Setup error log interface */ 827 818 rc = opal_elog_init(); 828 819 /* Setup code update interface */ 829 - opal_flash_init(); 820 + opal_flash_update_init(); 830 821 /* Setup platform dump extract interface */ 831 822 opal_platform_dump_init(); 832 823 /* Setup system parameters interface */ ··· 837 828 838 829 /* Initialize OPAL IPMI backend */ 839 830 opal_ipmi_init(opal_node); 831 + 832 + opal_flash_init(opal_node); 840 833 841 834 return 0; 842 835 } ··· 878 867 EXPORT_SYMBOL_GPL(opal_invalid_call); 879 868 EXPORT_SYMBOL_GPL(opal_ipmi_send); 880 869 EXPORT_SYMBOL_GPL(opal_ipmi_recv); 870 + EXPORT_SYMBOL_GPL(opal_flash_read); 871 + EXPORT_SYMBOL_GPL(opal_flash_write); 872 + EXPORT_SYMBOL_GPL(opal_flash_erase); 881 873 882 874 /* Convert a region of vmalloc memory to an opal sg list */ 883 875 struct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr,