(note: added the devicetree-discuss mailing list to this thread) On Wed, Feb 25, 2009 at 2:20 AM, Pieter <phenn...@vastech.co.za> wrote: > Hi all > > I am busy porting my board to Linux 2.6.27 from 2.6.19. The old Linux > was compiled using the ppc architecture, and had a "platform_device" > struct ure containing the custom devices on my board. ( > /arch/ppc/platform/sdh8548.c and /arch/ppc/platform/sdh8548.h ) > > I assume these devices should now be declared in the device tree source. > Building the new Linux using the powerpc architecture, but I am > strugeling translating teh information defined in the "platform_device" > to a device tree node. In particular what happens to the resource.flags > could anyone help please?
For the most common flags (IO_RESOURCE_MEM & IO_RESOURCE_IRQ), you use the 'reg' and 'interrupts' properties respectively to describe your device. The usage of them is well established. > Below is the "platform_device" definition and my interpretation of how > it should look in the device tree. Am I on the right track? Yes, you're on the right track; comments below > thanks pieter > > platform_device definition: > { > .name = "bio", > .id = 0, > .dev.platform_data = NULL, > .num_resources = 2, > .resource = (struct resource[]) { > { > .start = 0xe0100000, > .end = 0xe0100000 + 0x10000 -1, > .flags = IORESOURCE_MEM, /* 0x00000200 */ > }, > { > .name = "int", > .start = MPC85xx_IRQ_EXT0, /* 48 + > MPC85xx_OPENPIC_IRQ_OFFSET */ > .end = MPC85xx_IRQ_EXT0, > .flags = IORESOURCE_IRQ, /*0x00000400 */ > }, > }, > > FDT source: > local...@e0000000 { > #address-cells = <2>; > #size-cells = <1>; > compatible = "simple-bus"; > reg = <0xe0000000 0x5000>; > interrupt-parent = <&mpic>; > > ranges = < > 0x0 0x0 0xf8000000 0x07ffffff /*128MB Flash*/ > 0x1 0x0 0xe0200000 0x00200000 /*2MB FPGA*/ > 0x2 0x0 0xe0100000 0x00100000 /*1MB BIO CPLD*/ > >; Your ranges property appears to be correct. > ...@2,0 { > compatible = "wrs,epld-localbus"; This property is what the whole system hangs of and it is important that it is unique for the device you are describing. Device drivers read the compatible property and use it to decide whether or not it can drive the device. If this is a board-specific EPLD, then the name of the board should be part of the name. Once you've selected a name, you must document what the name means in Documentation/powerpc/dts-bindings/ and what properties are required in nodes with this value. > #address-cells = <2>; > #size-cells = <1>; Only use #address-cells and #size-cells if there is a child node that has a 'reg' property. > //interrupt-parent = <&mpic>; You don't need interrupt-parent if the parent node already sets it correctly. > //interrupts = <48>; This is probably where you are having trouble. To determine the format of the interrupts property you need to look at the interrupt parent node. The #interrupt-cells property in the interrupt parent will tell you how many numbers (cells) need to be in the interrupts property for each irq line. In this case the mpic specifies '#interrupt-cells=<2>;'. So, the interrupts property here should be in the form: "interrupts = < [irq-number] [irq-type] >;" irq-number is the irq line irq-type is the sense (edge/level, high/low). See mpic_host_xlate() in arch/powerpc/sysdev/mpic.c for the mapping (map_mpic_senses) between the irq-type value and the type of interrupt (duplicated here): static unsigned char map_mpic_senses[4] = { IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_FALLING, }; > reg = <0x2 0x0 0x0010000>; reg looks correct. > ranges = <0x0 0x0 0x2 0x0 0x00100000>; Only use ranges if there is a child node. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev