qe: add ability to upload QE firmware
Subsystems (2)
PATCH v5 1/1 qe: add ability to upload QE firmware
Define the layout of a binary blob that contains a QE firmware and instructions on how to upload it. Add function qe_upload_firmware() to parse the blob and perform the actual upload. Fully define 'struct rsp' in immap_qe.h to include the actual RISC Special Registers. Added description of a new QE firmware node to booting-without-of.txt.
---
Argh, another booting-without-of.txt fix. There are 8 virtual traps, not 16.
This patch is for Kumar's for-2.6.25 branch. This code is necessary for my QE UART driver.
Documentation/powerpc/00-INDEX | 3 + Documentation/powerpc/booting-without-of.txt | 33 +++- Documentation/powerpc/qe_firmware.txt | 295 ++++++++++++++++++++++++++ arch/powerpc/platforms/Kconfig | 1 + arch/powerpc/sysdev/qe_lib/qe.c | 240 +++++++++++++++++++++ include/asm-powerpc/immap_qe.h | 34 +++- include/asm-powerpc/qe.h | 61 ++++++ 7 files changed, 663 insertions(+), 4 deletions(-) create mode 100644 Documentation/powerpc/qe_firmware.txt
Documentation/powerpc/00-INDEX +3 -0
@@ -28,3 +28,6 @@ sound.txt - info on sound support under Linux/PPC zImage_layout.txt - info on the kernel images for Linux/PPC +qe_firmware.txt + - describes the layout of firmware binaries for the Freescale QUICC + Engine and the code that parses and uploads the microcode therein.
Documentation/powerpc/booting-without-of.txt +31 -2
@@ -52,7 +52,10 @@ Table of Contents i) Freescale QUICC Engine module (QE) j) CFI or JEDEC memory-mapped NOR flash k) Global Utilities Block - l) Xilinx IP cores + l) Freescale Communications Processor Module + m) Chipselect/Local Bus + n) 4xx/Axon EMAC ethernet nodes + o) Xilinx IP cores VII - Specifying interrupt information for devices 1) interrupts property
@@ -1772,6 +1775,32 @@ platforms are moved over to use the flattened-device-tree model. }; }; + viii) Uploaded QE firmware + + If a new firwmare has been uploaded to the QE (usually by the + boot loader), then a 'firmware' child node should be added to the QE + node. This node provides information on the uploaded firmware that + device drivers may need. + + Required properties: + - id: The string name of the firmware. This is taken from the 'id' + member of the qe_firmware structure of the uploaded firmware. + Device drivers can search this string to determine if the + firmware they want is already present. + - extended_modes: The Extended Modes bitfield, taken from the + firmware binary. It is a 64-bit number represented + as an array of two 32-bit numbers. + - virtual_traps: The virtual traps, taken from the firmware binary. + It is an array of 8 32-bit numbers. + + Example: + + firmware { + id = "Soft-UART"; + extended_modes = <0 0>; + virtual_traps = <0 0 0 0 0 0 0 0>; + } + j) CFI or JEDEC memory-mapped NOR flash Flash chips (Memory Technology Devices) are often used for solid state
@@ -2254,7 +2283,7 @@ platforms are moved over to use the flattened-device-tree model. available. For Axon: 0x0000012a - l) Xilinx IP cores + o) Xilinx IP cores The Xilinx EDK toolchain ships with a set of IP cores (devices) for use in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
Documentation/powerpc/qe_firmware.txt new file +295 -0
295 lines not on this page · raw message
arch/powerpc/platforms/Kconfig +1 -0
@@ -265,6 +265,7 @@ config TAU_AVERAGE config QUICC_ENGINE bool select PPC_LIB_RHEAP + select CRC32 help The QUICC Engine (QE) is a new generation of communications coprocessors on Freescale embedded CPUs (akin to CPM in older chips).
arch/powerpc/sysdev/qe_lib/qe.c +240 -0
249 lines not on this page · raw message
include/asm-powerpc/immap_qe.h +32 -2
@@ -393,9 +393,39 @@ struct dbg {u8 res2[0x48 ]; } __attribute__ ((packed)); -/* RISC Special Registers (Trap and Breakpoint) */ +/* +* RISC Special Registers (Trap and Breakpoint). These are described in +* the QE Developer's Handbook. +*/ struct rsp { -u32 reg[0x40 ];/* 64 32-bit registers */ +__be32 tibcr[16 ];/* Trap/instruction breakpoint control regs */ +u8 res0[64 ]; +__be32 ibcr0; +__be32 ibs0; +__be32 ibcnr0; +u8 res1[4 ]; +__be32 ibcr1; +__be32 ibs1; +__be32 ibcnr1; +__be32 npcr; +__be32 dbcr; +__be32 dbar; +__be32 dbamr; +__be32 dbsr; +__be32 dbcnr; +u8 res2[12 ]; +__be32 dbdr_h; +__be32 dbdr_l; +__be32 dbdmr_h; +__be32 dbdmr_l; +__be32 bsr; +__be32 bor; +__be32 bior; +u8 res3[4 ]; +__be32 iatr[4 ]; +__be32 eccr;/* Exception control configuration register */ +__be32 eicr; +u8 res4[0x100 -0xf8 ]; } __attribute__ ((packed));struct qe_immap {
include/asm-powerpc/qe.h +61 -0
73 lines not on this page · raw message
Signature · 1 line
1.5.2.4
Quoted 5 lines · Timur Tabi
Define the layout of a binary blob that contains a QE firmware and instructions on how to upload it. Add function
qe_upload_firmware()to parse the blob and perform the actual upload. Fully define 'struct rsp' inimmap_qe.hto include the actual RISC Special Registers. Added description of a new QE firmware node to booting-without-of.txt.
If there are no objections, I'd like this patch to be pulled into for-2.6.25. Thanks.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 8 lines · Timur Tabi
Quoted 5 lines · Timur Tabi
Define the layout of a binary blob that contains a QE firmware and instructions on how to upload it. Add function
qe_upload_firmware()to parse the blob and perform the actual upload. Fully define 'struct rsp' inimmap_qe.hto include the actual RISC Special Registers. Added description of a new QE firmware node to booting-without-of.txt.If there are no objections, I'd like this patch to be pulled into for-2.6.25. Thanks.
I'm just waiting for you to hit v99 :)
- k
Quoted 1 line · Timur Tabi
Define the layout of a binary blob that contains a QE firmware and instru=
ctions
Quoted 1 line
on how to upload it. =A0Add function
qe_upload_firmware()to parse the bl=
ob
Quoted 1 line
and perform the actual upload. =A0Fully define 'struct rsp' in immap_qe.h=
to
Quoted 2 lines
include the actual RISC Special Registers. =A0Added description of a new QE firmware node to booting-without-of.txt.
All the comments I had were addressed, mostly by convincing me that the code was correct to start with, so
Quoted 1 line
Signed-off-by Timur Tabi <[email protected]>
Quoted 29 lines · Timur Tabi
Define the layout of a binary blob that contains a QE firmware and instructions on how to upload it. Add function
qe_upload_firmware()to parse the blob and perform the actual upload. Fully define 'struct rsp' inimmap_qe.hto include the actual RISC Special Registers. Added description of a new QE firmware node to booting-without-of.txt.Signed-off-by Timur Tabi <[email protected]>---
Argh, another booting-without-of.txt fix. There are 8 virtual traps, not 16.
This patch is for Kumar's for-2.6.25 branch. This code is necessary for my QE UART driver.
Documentation/powerpc/00-INDEX | 3 + Documentation/powerpc/booting-without-of.txt | 33 +++- Documentation/powerpc/qe_firmware.txt | 295 ++++++++++++++++++++++++++ arch/powerpc/platforms/Kconfig | 1 + arch/powerpc/sysdev/qe_lib/qe.c | 240 +++++++++++++++++++++ include/asm-powerpc/immap_qe.h | 34 +++- include/asm-powerpc/qe.h | 61 ++++++ 7 files changed, 663 insertions(+), 4 deletions(-) create mode 100644 Documentation/powerpc/qe_firmware.txtDocumentation/powerpc/booting-without-of.txt +0
-0
...
Documentation/powerpc/booting-without-of.txt platforms are moved over to use the flattened-device-tree model. · line 1801
Quoted 7 lines
Documentation/powerpc/booting-without-of.txt +7
-0+ + Example: + + firmware { + id = "Soft-UART"; + extended_modes = <0 0>; + virtual_traps = <0 0 0 0 0 0 0 0>;
I believe using underscores for the property name is discouraged.
Quoted 2 lines
Documentation/powerpc/booting-without-of.txt +2
-0+ } +
...
Documentation/powerpc/booting-without-of.txt
Quoted 5 lines
Documentation/powerpc/booting-without-of.txt +5
-0+VI - Sample Code for Creating Firmware Files +============================================ + +A Python program that creates firmware binaries from the header files normally +distributed by Freescale can be found on http://opensource.freescale.com.
Hm... I didn't find it there. Could you provide more specific pointer?
...
Quoted 3 lines
index 1df3b4a..497eb88 100644
arch/powerpc/sysdev/qe_lib/qe.c +0
-0
...
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 550
Quoted 9 lines
arch/powerpc/sysdev/qe_lib/qe.c +9
-0+struct qe_firmware_info *qe_get_firmware_info (void ) +{ +static int initialized; + +/* +* If we haven't checked yet, and a driver hasn't uploaded a firmware +* yet, then check the device tree for information. +*/ + do {
^^^^
This is very unusual method of error handling. You could stick to gotos and lower the indentation level.
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 561
Quoted 11 lines
arch/powerpc/sysdev/qe_lib/qe.c +11
-0+struct device_node *qe; +struct device_node *fw =NULL ; +const char *sprop; +const u32 *iprop; + +if (initialized || qe_firmware_uploaded) +break ; + + initialized =1 ; + + qe =of_find_node_by_type (NULL ,"qe" );
Please, add compatible "fsl,qe" matching, so this code could work with new device trees.
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 568
Quoted 7 lines
arch/powerpc/sysdev/qe_lib/qe.c +7
-0+if (!qe) +break ; + +/* Find the 'firmware' child node */ +while ((fw =of_get_next_child (qe, fw))) +if (strcmp (fw->name,"firmware" ) ==0 ) +break ;
Hmm. Maybe of_find_node_by_name? Or better by compatible.
Quoted 6 lines
arch/powerpc/sysdev/qe_lib/qe.c +6
-0+ +/* Did we find the 'firmware' node? */ +if (!fw) { +of_node_put (qe); +break ; + }
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 584
Quoted 10 lines
arch/powerpc/sysdev/qe_lib/qe.c +10
-0+ + qe_firmware_uploaded =1 ; + +/* Copy the data into qe_firmware_info*/ + sprop =of_get_property (fw,"id" ,NULL ); +if (sprop) +strncpy (qe_firmware_info.id, sprop, +sizeof (qe_firmware_info.id) -1 ); + + iprop =of_get_property (fw,"extended_modes" ,NULL );
Checking for size?
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 589
Quoted 5 lines
arch/powerpc/sysdev/qe_lib/qe.c +5
-0+if (iprop) + qe_firmware_info.extended_modes = + (u64 ) iprop[0 ] <<32 | iprop[1 ]; + + iprop =of_get_property (fw,"virtual_traps" ,NULL );
size?
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Quoted 6 lines · Anton Vorontsov
Documentation/powerpc/booting-without-of.txt platforms are moved over to use the flattened-device-tree model. · line 1801
Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4
-0+ firmware { + id = "Soft-UART"; + extended_modes = <0 0>; + virtual_traps = <0 0 0 0 0 0 0 0>;I believe using underscores for the property name is discouraged.
Ugh, this one change would require me to repost all my patches. Oh well. I wish someone else had noticed it before I got to version 5.
I'll post a new version on January 7, when I get back to the office.
Quoted 4 lines
Documentation/powerpc/qe_firmware.txt line 295
Quoted 2 lines
Documentation/powerpc/qe_firmware.txt new file +2
-0+A Python program that creates firmware binaries from the header files normally +distributed by Freescale can be found on http://opensource.freescale.com.Hm... I didn't find it there. Could you provide more specific pointer?
I'll add those files only after my patches have been applied. The layout may change between now and then, and I don't want to have to repost the firmware.
Quoted 9 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 550
Quoted 6 lines
arch/powerpc/sysdev/qe_lib/qe.c +6
-0+ +/* +* If we haven't checked yet, and a driver hasn't uploaded a firmware +* yet, then check the device tree for information. +*/ + do {^^^^This is very unusual method of error handling. You could stick to gotos and lower the indentation level.
Ok, I'll change it. I wasn't crazy about it after I wrote it, anyway.
Quoted 4 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 561
Quoted 1 line
arch/powerpc/sysdev/qe_lib/qe.c +1
-0+ qe =of_find_node_by_type (NULL ,"qe" );Please, add compatible "fsl,qe" matching, so this code could work with new device trees.
Ok, but that new design was added after I posted this patch.
Quoted 6 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 568
Quoted 4 lines
arch/powerpc/sysdev/qe_lib/qe.c +4
-0+/* Find the 'firmware' child node */ +while ((fw =of_get_next_child (qe, fw))) +if (strcmp (fw->name,"firmware" ) ==0 ) +break ;Hmm. Maybe
of_find_node_by_name? Or better by compatible.
What's wrong with looking for the firmware node inside the QE node? That's the only place it can be?
Quoted 3 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 584
Quoted 1 line
arch/powerpc/sysdev/qe_lib/qe.c +1
-0+ iprop =of_get_property (fw,"extended_modes" ,NULL );Checking for size?
Ok.
Quoted 11 lines · Timur Tabi
Quoted 6 lines · Anton Vorontsov
Documentation/powerpc/booting-without-of.txt platforms are moved over to use the flattened-device-tree model. · line 1801
Quoted 4 lines
Documentation/powerpc/booting-without-of.txt +4
-0+ firmware { + id = "Soft-UART"; + extended_modes = <0 0>; + virtual_traps = <0 0 0 0 0 0 0 0>;I believe using underscores for the property name is discouraged.
Ugh, this one change would require me to repost all my patches. Oh well. I wish someone else had noticed it before I got to version 5.
Yeah, sorry about that.
But you know it, reviewing is tedious, and only few of us are doing reviews for the code they don't use.
I've started to use this code just now, so I reviewed it on the way.
Quoted 37 lines
I'll post a new version on January 7, when I get back to the office.
Quoted 4 lines
Documentation/powerpc/qe_firmware.txt line 295
Quoted 2 lines
Documentation/powerpc/qe_firmware.txt new file +2
-0+A Python program that creates firmware binaries from the header files normally +distributed by Freescale can be found on http://opensource.freescale.com.Hm... I didn't find it there. Could you provide more specific pointer?
I'll add those files only after my patches have been applied. The layout may change between now and then, and I don't want to have to repost the firmware.
Quoted 9 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 550
Quoted 6 lines
arch/powerpc/sysdev/qe_lib/qe.c +6
-0+ +/* +* If we haven't checked yet, and a driver hasn't uploaded a firmware +* yet, then check the device tree for information. +*/ + do {^^^^This is very unusual method of error handling. You could stick to gotos and lower the indentation level.
Ok, I'll change it. I wasn't crazy about it after I wrote it, anyway.
Quoted 4 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 561
Quoted 1 line
arch/powerpc/sysdev/qe_lib/qe.c +1
-0+ qe =of_find_node_by_type (NULL ,"qe" );Please, add compatible "fsl,qe" matching, so this code could work with new device trees.
Ok, but that new design was added after I posted this patch.
Quoted 6 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 568
Quoted 4 lines
arch/powerpc/sysdev/qe_lib/qe.c +4
-0+/* Find the 'firmware' child node */ +while ((fw =of_get_next_child (qe, fw))) +if (strcmp (fw->name,"firmware" ) ==0 ) +break ;Hmm. Maybe
of_find_node_by_name? Or better by compatible.
Quoted 2 lines
What's wrong with looking for the firmware node inside the QE node? That's the only place it can be?
Ah, I see it now. Revoking my comment.
Quoted 5 lines
Quoted 3 lines
arch/powerpc/sysdev/qe_lib/qe.c void *qe_muram_addr(unsigned long offset) · line 584
Quoted 1 line
arch/powerpc/sysdev/qe_lib/qe.c +1
-0+ iprop =of_get_property (fw,"extended_modes" ,NULL );Checking for size?
Ok.
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Quoted 2 lines · Anton Vorontsov
Please, add compatible "fsl,qe" matching, so this code could work with new device trees.
Can you give me an example of this? I cannot find a single device tree anywhere that has this compatible property in it.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale