Generic file system firmware loader DM
cover Generic file system firmware loader DM
From: Tien Fong Chee <[email protected]>
This patchset contains generic file system loader DM which is very close to Linux firmware loader but for U-Boot framework. Generic file system firmware loader can be used load whatever into target location, and then consumer driver would use it to program whatever, ie. the FPGA.
This series is working on top of u-boot-socfpga.git -
http://git.denx.de/u-boot-socfpga.git .
Tien Fong Chee (3):
doc: Add new doc for file system firmware loader driver model
doc: dtbinding: Add file system firmware loader binding document
common: Generic loader for file system
doc/device-tree-bindings/misc/fs_loader.txt | 48 ++++++ doc/driver-model/fs_firmware_loader.txt | 100 +++++++++++ drivers/misc/Kconfig | 11 ++ drivers/misc/Makefile | 1 + drivers/misc/fs_loader.c | 240 +++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/fs_loader.h | 28 +++ 7 files changed, 429 insertions(+), 0 deletions(-) create mode 100644 doc/device-tree-bindings/misc/fs_loader.txt create mode 100644 doc/driver-model/fs_firmware_loader.txt create mode 100644 drivers/misc/fs_loader.c create mode 100644 include/fs_loader.h
Signature · 1 line
1.7.7.4
PATCH 1/3 doc: Add new doc for file system firmware loader driver model
From: Tien Fong Chee <[email protected]>
Provide information about
- overview of file system firmware loader driver model
- describe default storage device in device tree source
- describe fie system firmware loader API
--- doc/driver-model/fs_firmware_loader.txt | 100 +++++++++++++++++++++++++++++++ 1 files changed, 100 insertions(+), 0 deletions(-) create mode 100644 doc/driver-model/fs_firmware_loader.txt
doc/driver-model/fs_firmware_loader.txt new file +100 -0
@@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Intel Corporation <www.intel.com> + * + * SPDX-License-Identifier: GPL-2.0 + */ + +Introduction +------------ +This is file system firmware loader for U-Boot framework, which has very close +to some Linux Firmware API. For the details of Linux Firmware API, you can refer +to https://01.org/linuxgraphics/gfx-docs/drm/driver-api/firmware/index.html. + +File system firmware loader can be used to load whatever(firmware, image, +and binary) from the storage device in file system format into target location +such as memory, then consumer driver such as FPGA driver can program FPGA image +from the target location into FPGA. + +To enable firmware loader driver model, CONFIG_FS_LOADER need to be set at +<board_name>_defconfig such as "CONFIG_FS_LOADER=y". + +Firmware Loader API core features +--------------------------------- +=> Firmware storage device described in device tree source + ---------------------------------------- + => Example of default storage device partition search set for mmc, usb, + sata and ubi as shown in below: + Example for mmc: + fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "mmc"; + devpart = "0:1"; + }; + + Example for usb: + fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "usb"; + devpart = "0:1"; + }; + + Example for sata: + fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "sata"; + devpart = "0:1"; + }; + + Example for ubi: + fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "ubi"; + mtdpart = "UBI", + ubivol = "ubi0"; + }; + + + However, the default fs_loader with property devpart, mtdpart, and + ubivol values can be overwritten with value which is defined in the + environment variable "fw_dev_part", "fw_ubi_mtdpart", and + "fw_ubi_volume" respectively. + For example: env_set("fw_dev_part", "0:2"); + +File system firmware Loader API +------------------------------- +=> int request_firmware_into_buf(struct udevice *dev, + struct firmware **firmware_p, + const char *name, + void *buf, size_t size, u32 offset) + ----------------------------------------------------------------- + => Load firmware into a previously allocated buffer + + Parameters: + struct udevice *dev + An instance of a driver + + struct firmware **firmware_p + pointer to firmware image + + const char *name + name of firmware file + + void *buf + address of buffer to load firmware into + + size_t size + size of buffer + + u32 offset + offset of a file for start reading into buffer + + return: size of total read + -ve when error + + Description: + The firmware is loaded directly into the buffer pointed to by buf and + the @firmware_p data member is pointed at buf.
Signature · 1 line
1.7.7.4
PATCH 1/3 doc: Add new doc for file system firmware loader driver model
Quoted 20 lines · tien.fong.chee at intel.com
From: Tien Fong Chee <[email protected]>
Provide information about
- overview of file system firmware loader driver model
- describe default storage device in device tree source
- describe fie system firmware loader APISigned-off-by Tien Fong Chee <[email protected]>--- doc/driver-model/fs_firmware_loader.txt | 100 +++++++++++++++++++++++++++++++ 1 files changed, 100 insertions(+), 0 deletions(-) create mode 100644 doc/driver-model/fs_firmware_loader.txtdoc/driver-model/fs_firmware_loader.txt new file +0
-0
doc/driver-model/fs_firmware_loader.txt line 5
Quoted 5 lines
doc/driver-model/fs_firmware_loader.txt new file +5
-0@@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Intel Corporation <www.intel.com> + * + * SPDX-License-Identifier: GPL-2.0 + */
As this isn't code please don't put a code header up for the first comment block. Frankly I'd rather see an rST comment block up front even with the rest being plain text as long term I imagine we'll move to rST.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180516/d78e2f33/attachment.sig>
Chee
PATCH 1/3 doc: Add new doc for file system firmware loader driver model
Quoted 28 lines · Tom Rini
Quoted 25 lines · tien.fong.chee at intel.com
From: Tien Fong Chee <[email protected]>
Provide information about
- overview of file system firmware loader driver model
- describe default storage device in device tree source
- describe fie system firmware loader APISigned-off-by Tien Fong Chee <[email protected]>---
doc/driver-model/fs_firmware_loader.txt | 100
+++++++++++++++++++++++++++++++1 files changed, 100 insertions(+), 0 deletions(-)create mode 100644
doc/driver-model/fs_firmware_loader.txtdoc/driver- renamed from doc/driver-model/fs_firmware_loader.txt +0
-0
model/fs_firmware_loader.txt
new file mode 100644
index 0000000..167660adoc/driver-model/fs_firmware_loader.txt new file +2
-0@@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Intel Corporation <www.intel.com>
Quoted 9 lines
doc/driver-model/fs_firmware_loader.txt line 5
Quoted 3 lines
doc/driver-model/fs_firmware_loader.txt new file +3
-0+ * + * SPDX-License-Identifier: GPL-2.0 + */As this isn't code please don't put a code header up for the first comment block. Frankly I'd rather see an rST comment block up front even with the rest being plain text as long term I imagine we'll move to
rST.
Okay, i will remove the license and changing it to rST format.
PATCH 1/3 doc: Add new doc for file system firmware loader driver model
Quoted 38 lines · Tien Fong
Quoted 28 lines · Tom Rini
Quoted 25 lines · tien.fong.chee at intel.com
From: Tien Fong Chee <[email protected]>
Provide information about
- overview of file system firmware loader driver model
- describe default storage device in device tree source
- describe fie system firmware loader APISigned-off-by Tien Fong Chee <[email protected]>---
doc/driver-model/fs_firmware_loader.txt | 100
+++++++++++++++++++++++++++++++1 files changed, 100 insertions(+), 0 deletions(-)create mode 100644
doc/driver-model/fs_firmware_loader.txtdoc/driver- renamed from doc/driver-model/fs_firmware_loader.txt +0
-0
model/fs_firmware_loader.txt
new file mode 100644
index 0000000..167660adoc/driver-model/fs_firmware_loader.txt new file +2
-0@@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Intel Corporation <www.intel.com>Quoted 9 lines
doc/driver-model/fs_firmware_loader.txt line 5
Quoted 3 lines
doc/driver-model/fs_firmware_loader.txt new file +3
-0+ * + * SPDX-License-Identifier: GPL-2.0 + */As this isn't code please don't put a code header up for the first comment block. Frankly I'd rather see an rST comment block up front even with the rest being plain text as long term I imagine we'll move to
rST.
Quoted 1 line
Okay, i will remove the license and changing it to rST format.
You don't need to remove it, just move it :)
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180517/d7b84e5d/attachment.sig>
Chee
PATCH 1/3 doc: Add new doc for file system firmware loader driver model
Quoted 47 lines · Tom Rini
Quoted 46 lines · Tien Fong
Quoted 44 lines · Tom Rini
Quoted 25 lines · tien.fong.chee at intel.co m
From: Tien Fong Chee <[email protected]>
Provide information about
- overview of file system firmware loader driver model
- describe default storage device in device tree source
- describe fie system firmware loader APISigned-off-by Tien Fong Chee <[email protected]>---
doc/driver-model/fs_firmware_loader.txt | 100
+++++++++++++++++++++++++++++++1 files changed, 100 insertions(+), 0 deletions(-)create mode 100644
doc/driver-model/fs_firmware_loader.txtdoc/driver- renamed from doc/driver-model/fs_firmware_loader.txt +0
-0
model/fs_firmware_loader.txt
new file mode 100644
index 0000000..167660adoc/driver-model/fs_firmware_loader.txt line 5
Quoted 5 lines
doc/driver-model/fs_firmware_loader.txt new file +5
-0@@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Intel Corporation <www.intel.com> + * + * SPDX-License-Identifier: GPL-2.0 + */As this isn't code please don't put a code header up for the first
comment block. Frankly I'd rather see an rST comment block up front
even with the rest being plain text as long term I imagine we'll move
to
rST.
Quoted 3 lines
Quoted 1 line
Okay, i will remove the license and changing it to rST format.
You don't need to remove it, just move it :)
Ohh....i just need to change the license and copyright header to rST format?
PATCH 2/3 doc: dtbinding: Add file system firmware loader binding document
In reply to tien.fong.chee at intel.comFrom: Tien Fong Chee <[email protected]>
Add a document to describe file system firmware loader binding information.
--- doc/device-tree-bindings/misc/fs_loader.txt | 48 +++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 doc/device-tree-bindings/misc/fs_loader.txt
doc/device-tree-bindings/misc/fs_loader.txt new file +48 -0
@@ -0,0 +1,48 @@ +File system firmware loader + +Required properties: +- compatible: should contain "fs_loader" +- storage_device: which storage device loading from, could be: + - mmc, usb, sata, and ubi. +- devpart: which storage device and partition the image loading from, + this property is required for mmc, usb and sata. +- mdtpart: which partition of ubi the image loading from, this property is + required for ubi. +- ubivol: which volume of ubi the image loading from, this proprety is required + for ubi. + +=> Example of default storage device partition search set for mmc, usb, sata and +ubi in device tree source as shown in below: + +Example for mmc: +fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "mmc"; + devpart = "0:1"; +}; + +Example for usb: +fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "usb"; + devpart = "0:1"; +}; + +Example for sata: +fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "sata"; + devpart = "0:1"; +}; + +Example for ubi: +fs_loader { + u-boot,dm-pre-reloc; + compatible = "fs_loader"; + storage_device = "ubi"; + mtdpart = "UBI", + ubivol = "ubi0"; +};
Signature · 1 line
1.7.7.4
PATCH 3/3 common: Generic loader for file system
In reply to tien.fong.chee at intel.comFrom: Tien Fong Chee <[email protected]>
This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever, ie. the FPGA device.
--- drivers/misc/Kconfig | 11 ++ drivers/misc/Makefile | 1 + drivers/misc/fs_loader.c | 240 ++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/fs_loader.h | 28 ++++++ 5 files changed, 281 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/fs_loader.c create mode 100644 include/fs_loader.h
drivers/misc/Kconfig +11 -0
@@ -268,4 +268,15 @@ config GDSYS_RXAUI_CTRL depends on MISC help Support gdsys FPGA's RXAUI control. + +config FS_LOADER + bool "Enable loader driver for file system" + depends on DM + help + This is file system generic loader which can be used to load + the file image from the storage into target such as memory. + + The consumer driver would then use this loader to program whatever, + ie. the FPGA device. + endmenu
drivers/misc/Makefile +1 -0
@@ -53,3 +53,4 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o obj-$(CONFIG_STM32_RCC) += stm32_rcc.o obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o +obj-$(CONFIG_FS_LOADER) += fs_loader.o
drivers/misc/fs_loader.c new file +240 -0
240 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -36,6 +36,7 @@ enum uclass_id {UCLASS_DMA ,/* Direct Memory Access */ UCLASS_EFI ,/* EFI managed devices */ UCLASS_ETH ,/* Ethernet device */ +UCLASS_FS_FIRMWARE_LOADER ,/* Generic loader */ UCLASS_GPIO ,/* Bank of general-purpose I/O pins */ UCLASS_FIRMWARE ,/* Firmware */ UCLASS_I2C, /* I2C bus */
include/fs_loader.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (C) 2018 Intel Corporation <www.intel.com> +* +* SPDX-License-Identifier: GPL-2.0 +*/ +#ifndef _FS_LOADER_H_ +#define _FS_LOADER_H_ + +#include <dm.h> + +struct firmware { +size_t size;/* Size of a file */ +const u8 *data;/* Buffer for file */ +void *priv;/* Firmware loader private fields */ +}; + +struct device_platdata { +char *name;/* Such as mmc, usb,and sata. */ +char *devpart;/* Use the load command dev:part conventions */ +char *mtdpart;/* MTD partition for ubi part */ +char *ubivol;/* UBI volume-name for ubifsmount */ +}; + +int request_firmware_into_buf (struct udevice *dev, +struct firmware **firmware_p, +const char *name, +void *buf,size_t size,u32 offset); +#endif
Signature · 1 line
1.7.7.4