* [RFC] PlatformDevice definitions for 82xx
From: Vitaly Bordug @ 2005-06-02 16:16 UTC (permalink / raw)
To: linuxppc-embedded list
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
Hi!
This adds platform definition files for 82xx, while the platform_info is
filled in board-specific .C file residing in platforms/82xx. Another
disputable thing I did - I moved m8260_setup.c from the syslib/ up to
platforms/82xx/. The file was slightly changed - added 2 prototypes
from the cpm2_pic.h and removed the respective include.
These defs will be utilized by fs_enet driver which is developed
currently by Pantelis and me.
Comments, suggestions appreciated.
--
Sincerely,
Vitaly
[-- Attachment #2: platf_init.patch --]
[-- Type: text/x-patch, Size: 30073 bytes --]
initial platform defenitions
---
commit 1a7a351106fed3353484b808074522e223b012a6
tree 072e120576417512a61676af3bfc422268ebfdf9
parent 88d7bd8cb9eb8d64bf7997600b0d64f7834047c5
author Vitaly Bordug <vvv@localhost.localdomain> 1117637659 +0400
committer Vitaly Bordug <vvv@localhost.localdomain> 1117637659 +0400
Index: arch/ppc/Makefile
===================================================================
--- eed337ef5e9ae7d62caa84b7974a11fddc7f06e0/arch/ppc/Makefile (mode:100644 sha1:0432a25b47354e75d0a09e4b2817d1afe7849313)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/Makefile (mode:100644 sha1:b251420f5dd9e85be90699e682799ff1e6993cc4)
@@ -60,6 +60,7 @@
core-$(CONFIG_4xx) += arch/ppc/platforms/4xx/
core-$(CONFIG_83xx) += arch/ppc/platforms/83xx/
core-$(CONFIG_85xx) += arch/ppc/platforms/85xx/
+core-$(CONFIG_8260) += arch/ppc/platforms/82xx/
core-$(CONFIG_MATH_EMULATION) += arch/ppc/math-emu/
core-$(CONFIG_XMON) += arch/ppc/xmon/
core-$(CONFIG_APUS) += arch/ppc/amiga/
Index: arch/ppc/platforms/82xx/Makefile
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/platforms/82xx/Makefile (mode:100644 sha1:6909aa63a062de13c246439b5fd97b4c45b110db)
@@ -0,0 +1,4 @@
+#
+# Makefile for the PowerPC 82xx linux kernel.
+#
+obj-$(CONFIG_8260) += m8260_setup.o pq2ads_pd.o
\ No newline at end of file
Index: arch/ppc/platforms/82xx/m8260_setup.c
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/platforms/82xx/m8260_setup.c (mode:100644 sha1:77d88db0490ccf71ddad38f6b10d0698e7aeb4cb)
@@ -0,0 +1,268 @@
+/*
+ * arch/ppc/syslib/m8260_setup.c
+ *
+ * Copyright (C) 1995 Linus Torvalds
+ * Adapted from 'alpha' version by Gary Thomas
+ * Modified by Cort Dougan (cort@cs.nmt.edu)
+ * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
+ * Further modified for generic 8xx and 8260 by Dan.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/stddef.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/initrd.h>
+#include <linux/root_dev.h>
+#include <linux/seq_file.h>
+#include <linux/irq.h>
+
+#include <asm/mmu.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/mpc8260.h>
+#include <asm/immap_cpm2.h>
+#include <asm/machdep.h>
+#include <asm/bootinfo.h>
+#include <asm/time.h>
+
+
+unsigned char __res[sizeof(bd_t)];
+
+extern int cpm2_get_irq(struct pt_regs *regs);
+extern void cpm2_init_IRQ(void);
+
+extern void cpm2_reset(void);
+extern void m8260_find_bridges(void);
+extern void idma_pci9_init(void);
+extern void pq2_setup_pd(void);
+
+/* Place-holder for board-specific init */
+void __attribute__ ((weak)) __init
+m82xx_board_setup(void)
+{
+}
+
+static void __init
+m8260_setup_arch(void)
+{
+ /* Print out Vendor and Machine info. */
+ printk(KERN_INFO "%s %s port\n", CPUINFO_VENDOR, CPUINFO_MACHINE);
+
+ /* Reset the Communication Processor Module. */
+ cpm2_reset();
+#ifdef CONFIG_8260_PCI9
+ /* Initialise IDMA for PCI erratum workaround */
+ idma_pci9_init();
+#endif
+#ifdef CONFIG_PCI_8260
+ m8260_find_bridges();
+#endif
+#ifdef CONFIG_BLK_DEV_INITRD
+ if (initrd_start)
+ ROOT_DEV = Root_RAM0;
+#endif
+ m82xx_board_setup();
+ pq2_setup_pd();
+}
+
+/* The decrementer counts at the system (internal) clock frequency
+ * divided by four.
+ */
+static void __init
+m8260_calibrate_decr(void)
+{
+ bd_t *binfo = (bd_t *)__res;
+ int freq, divisor;
+
+ freq = binfo->bi_busfreq;
+ divisor = 4;
+ tb_ticks_per_jiffy = freq / HZ / divisor;
+ tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
+}
+
+/* The 8260 has an internal 1-second timer update register that
+ * we should use for this purpose.
+ */
+static uint rtc_time;
+
+static int
+m8260_set_rtc_time(unsigned long time)
+{
+ rtc_time = time;
+
+ return(0);
+}
+
+static unsigned long
+m8260_get_rtc_time(void)
+{
+ /* Get time from the RTC.
+ */
+ return((unsigned long)rtc_time);
+}
+
+#ifndef BOOTROM_RESTART_ADDR
+#warning "Using default BOOTROM_RESTART_ADDR!"
+#define BOOTROM_RESTART_ADDR 0xff000104
+#endif
+
+static void
+m8260_restart(char *cmd)
+{
+ extern void m8260_gorom(bd_t *bi, uint addr);
+ uint startaddr;
+
+ /* Most boot roms have a warmstart as the second instruction
+ * of the reset vector. If that doesn't work for you, change this
+ * or the reboot program to send a proper address.
+ */
+ startaddr = BOOTROM_RESTART_ADDR;
+ if (cmd != NULL) {
+ if (!strncmp(cmd, "startaddr=", 10))
+ startaddr = simple_strtoul(&cmd[10], NULL, 0);
+ }
+
+ m8260_gorom((void*)__pa(__res), startaddr);
+}
+
+static void
+m8260_halt(void)
+{
+ local_irq_disable();
+ while (1);
+}
+
+static void
+m8260_power_off(void)
+{
+ m8260_halt();
+}
+
+static int
+m8260_show_cpuinfo(struct seq_file *m)
+{
+ bd_t *bp = (bd_t *)__res;
+
+ seq_printf(m, "vendor\t\t: %s\n"
+ "machine\t\t: %s\n"
+ "\n"
+ "mem size\t\t: 0x%08x\n"
+ "console baud\t\t: %d\n"
+ "\n"
+ "core clock\t: %u MHz\n"
+ "CPM clock\t: %u MHz\n"
+ "bus clock\t: %u MHz\n",
+ CPUINFO_VENDOR, CPUINFO_MACHINE, bp->bi_memsize,
+ bp->bi_baudrate, bp->bi_intfreq / 1000000,
+ bp->bi_cpmfreq / 1000000, bp->bi_busfreq / 1000000);
+ return 0;
+}
+
+/* Initialize the internal interrupt controller. The number of
+ * interrupts supported can vary with the processor type, and the
+ * 8260 family can have up to 64.
+ * External interrupts can be either edge or level triggered, and
+ * need to be initialized by the appropriate driver.
+ */
+static void __init
+m8260_init_IRQ(void)
+{
+ cpm2_init_IRQ();
+
+ /* Initialize the default interrupt mapping priorities,
+ * in case the boot rom changed something on us.
+ */
+ cpm2_immr->im_intctl.ic_siprr = 0x05309770;
+}
+
+/*
+ * Same hack as 8xx
+ */
+static unsigned long __init
+m8260_find_end_of_memory(void)
+{
+ bd_t *binfo = (bd_t *)__res;
+
+ return binfo->bi_memsize;
+}
+
+/* Map the IMMR, plus anything else we can cover
+ * in that upper space according to the memory controller
+ * chip select mapping. Grab another bunch of space
+ * below that for stuff we can't cover in the upper.
+ */
+static void __init
+m8260_map_io(void)
+{
+ uint addr;
+
+ /* Map IMMR region to a 256MB BAT */
+ addr = (cpm2_immr != NULL) ? (uint)cpm2_immr : CPM_MAP_ADDR;
+ io_block_mapping(addr, addr, 0x10000000, _PAGE_IO);
+
+ /* Map I/O region to a 256MB BAT */
+ io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO);
+}
+
+/* Place-holder for board-specific ppc_md hooking */
+void __attribute__ ((weak)) __init
+m82xx_board_init(void)
+{
+}
+
+/* Inputs:
+ * r3 - Optional pointer to a board information structure.
+ * r4 - Optional pointer to the physical starting address of the init RAM
+ * disk.
+ * r5 - Optional pointer to the physical ending address of the init RAM
+ * disk.
+ * r6 - Optional pointer to the physical starting address of any kernel
+ * command-line parameters.
+ * r7 - Optional pointer to the physical ending address of any kernel
+ * command-line parameters.
+ */
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7)
+{
+ parse_bootinfo(find_bootinfo());
+
+ if ( r3 )
+ memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
+
+#ifdef CONFIG_BLK_DEV_INITRD
+ /* take care of initrd if we have one */
+ if ( r4 ) {
+ initrd_start = r4 + KERNELBASE;
+ initrd_end = r5 + KERNELBASE;
+ }
+#endif /* CONFIG_BLK_DEV_INITRD */
+ /* take care of cmd line */
+ if ( r6 ) {
+ *(char *)(r7+KERNELBASE) = 0;
+ strcpy(cmd_line, (char *)(r6+KERNELBASE));
+ }
+
+ ppc_md.setup_arch = m8260_setup_arch;
+ ppc_md.show_cpuinfo = m8260_show_cpuinfo;
+ ppc_md.init_IRQ = m8260_init_IRQ;
+ ppc_md.get_irq = cpm2_get_irq;
+
+ ppc_md.restart = m8260_restart;
+ ppc_md.power_off = m8260_power_off;
+ ppc_md.halt = m8260_halt;
+
+ ppc_md.set_rtc_time = m8260_set_rtc_time;
+ ppc_md.get_rtc_time = m8260_get_rtc_time;
+ ppc_md.calibrate_decr = m8260_calibrate_decr;
+
+ ppc_md.find_end_of_memory = m8260_find_end_of_memory;
+ ppc_md.setup_io_mappings = m8260_map_io;
+
+ /* Call back for board-specific settings and overrides. */
+ m82xx_board_init();
+}
Index: arch/ppc/platforms/82xx/pq2ads_pd.c
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/platforms/82xx/pq2ads_pd.c (mode:100644 sha1:e4c6ce54f2d8def183dbdc6490c0a9bbcb9c9470)
@@ -0,0 +1,117 @@
+/*
+ * arch/ppc/platforms/82xx/pq2ads_pd.c
+ *
+ * MPC82xx Board-specific PlatformDevice descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <linux/fs_enet_pd.h>
+
+#include <asm/mpc8260.h>
+#include <asm/cpm2.h>
+#include <asm/immap_cpm2.h>
+#include <asm/irq.h>
+#include <asm/ppc_sys.h>
+#include <asm/ppcboot.h>
+
+#include "pq2ads_pd.h"
+
+static struct fs_mii_bus_info mii_bus_info = {
+ .method = fsmii_bitbang,
+ .id = 0,
+ .i.bitbang = {
+ .mdio_port = fsiop_portc,
+ .mdio_bit = 9,
+ .mdc_port = fsiop_portc,
+ .mdc_bit = 10,
+ .delay = 1,
+ },
+};
+
+
+/*
+ The PHY_INTERRUPT crap is odd but will be replaced by pmac-like feature_call
+ as soon as it will be checked in. -vb
+ */
+
+static struct fs_platform_info mpc82xx_fcc1_pdata = {
+ .fs_no = fsid_fcc1,
+ .cp_page = CPM_CR_FCC1_PAGE,
+ .cp_block = CPM_CR_FCC1_SBLOCK,
+ .clk_trx = (PC_F1RXCLK | PC_F1TXCLK),
+ .clk_route = CMX1_CLK_ROUTE,
+ .clk_mask = CMX1_CLK_MASK,
+ .mdio = PC_MDIO,
+ .mdck = PC_MDCK,
+
+ .phy_addr = -1,
+#ifdef PHY_INTERRUPT
+ .phy_irq = PHY_INTERRUPT,
+#endif
+ .bus_info = &mii_bus_info,
+ .rx_ring = 32,
+ .tx_ring = 32,
+ .rx_copybreak = 240,
+ .use_napi = 0,
+ .napi_weight = 17,
+};
+
+static struct fs_platform_info mpc82xx_fcc2_pdata = {
+ .fs_no = fsid_fcc2,
+ .cp_page = CPM_CR_FCC2_PAGE,
+ .cp_block = CPM_CR_FCC2_SBLOCK,
+ .clk_trx = (PC_F2RXCLK | PC_F2TXCLK),
+ .clk_route = CMX2_CLK_ROUTE,
+ .clk_mask = CMX2_CLK_MASK,
+ .mdio = PC_MDIO,
+ .mdck = PC_MDCK,
+
+ .phy_addr = -1,
+#ifdef PHY_INTERRUPT
+ .phy_irq = PHY_INTERRUPT,
+#endif
+
+ .bus_info = &mii_bus_info,
+ .rx_ring = 32,
+ .tx_ring = 32,
+ .rx_copybreak = 240,
+ .use_napi = 0,
+ .napi_weight = 17,
+};
+
+
+void pq2_setup_pd(void)
+{
+ bd_t* bi = (void*)__res;
+
+ /* first we need to identify platform on the bus */
+ identify_ppc_sys_by_id(cpm2_immr->im_memctl.memc_immr << 16);
+
+ /* Do some runtime PD setup */
+ memcpy(&mpc82xx_fcc1_pdata.macaddr,bi->bi_enetaddr,6);
+
+ /* Since some boards have 2 or more MAC's passed from the firmware, you may replace
+ the stuff below by the real address (bi->enet1addr & so on) but first ensure that
+ respective struct contain field you wish to use here */
+ memcpy(&mpc82xx_fcc2_pdata.macaddr,bi->bi_enetaddr,6);
+ mpc82xx_fcc2_pdata.macaddr[5] ^= 1;
+
+ /* At last wi fill the platform_data pointers with respective data */
+ ppc_sys_platform_devices[MPC82xx_FCC1].dev.platform_data = &mpc82xx_fcc1_pdata;
+ ppc_sys_platform_devices[MPC82xx_FCC2].dev.platform_data = &mpc82xx_fcc2_pdata;
+
+}
+
Index: arch/ppc/platforms/82xx/pq2ads_pd.h
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/platforms/82xx/pq2ads_pd.h (mode:100644 sha1:4debf007859d6043d0647f8f3e6741834b78b689)
@@ -0,0 +1,63 @@
+#ifndef __PQ2ADS_PD_H
+#define __PQ2ADS_PD_H
+/*
+ * arch/ppc/platforms/82xx/pq2ads_pd.h
+ *
+ * Some defines for MPC82xx board-specific PlatformDevice descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+/* FCC1 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK9-12 */
+
+#define F1_RXCLK 11
+#define F1_TXCLK 10
+
+/* FCC2 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK13-16 */
+#define F2_RXCLK 15
+#define F2_TXCLK 16
+
+/* FCC3 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK13-16 */
+#define F3_RXCLK 15
+#define F3_TXCLK 16
+
+/* MDIO and MDCK settings. These can be redefined in the board specific file.*/
+#define PC_MDIO 0x00002000U
+#define PC_MDCK 0x00001000U
+
+/* Automatically generates register configurations */
+#define PC_CLK(x) ((uint)(1<<(x-1))) /* FCC CLK I/O ports */
+
+#define CMXFCR_RF1CS(x) ((uint)((x-5)<<27)) /* FCC1 Receive Clock Source */
+#define CMXFCR_TF1CS(x) ((uint)((x-5)<<24)) /* FCC1 Transmit Clock Source */
+#define CMXFCR_RF2CS(x) ((uint)((x-9)<<19)) /* FCC2 Receive Clock Source */
+#define CMXFCR_TF2CS(x) ((uint)((x-9)<<16)) /* FCC2 Transmit Clock Source */
+#define CMXFCR_RF3CS(x) ((uint)((x-9)<<11)) /* FCC3 Receive Clock Source */
+#define CMXFCR_TF3CS(x) ((uint)((x-9)<<8)) /* FCC3 Transmit Clock Source */
+
+#define PC_F1RXCLK PC_CLK(F1_RXCLK)
+#define PC_F1TXCLK PC_CLK(F1_TXCLK)
+#define CMX1_CLK_ROUTE (CMXFCR_RF1CS(F1_RXCLK) | CMXFCR_TF1CS(F1_TXCLK))
+#define CMX1_CLK_MASK ((uint)0xff000000)
+
+#define PC_F2RXCLK PC_CLK(F2_RXCLK)
+#define PC_F2TXCLK PC_CLK(F2_TXCLK)
+#define CMX2_CLK_ROUTE (CMXFCR_RF2CS(F2_RXCLK) | CMXFCR_TF2CS(F2_TXCLK))
+#define CMX2_CLK_MASK ((uint)0x00ff0000)
+
+#define PC_F3RXCLK PC_CLK(F3_RXCLK)
+#define PC_F3TXCLK PC_CLK(F3_TXCLK)
+#define CMX3_CLK_ROUTE (CMXFCR_RF3CS(F3_RXCLK) | CMXFCR_TF3CS(F3_TXCLK))
+#define CMX3_CLK_MASK ((uint)0x0000ff00)
+
+#endif
Index: arch/ppc/syslib/Makefile
===================================================================
--- eed337ef5e9ae7d62caa84b7974a11fddc7f06e0/arch/ppc/syslib/Makefile (mode:100644 sha1:dd418ea3426c70a4ed065986e464967fce8122fb)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/syslib/Makefile (mode:100644 sha1:ed2da02b7bba6780761857ccb082e4a5b5704fe1)
@@ -80,10 +80,11 @@
obj-$(CONFIG_SBC82xx) += todc_time.o
obj-$(CONFIG_SPRUCE) += cpc700_pic.o indirect_pci.o pci_auto.o \
todc_time.o
-obj-$(CONFIG_8260) += m8260_setup.o
obj-$(CONFIG_PCI_8260) += m8260_pci.o indirect_pci.o
obj-$(CONFIG_8260_PCI9) += m8260_pci_erratum9.o
-obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o
+obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o \
+ mpc82xx_devices.o mpc82xx_sys.o ppc_sys.o
+
ifeq ($(CONFIG_PPC_GEN550),y)
obj-$(CONFIG_KGDB) += gen550_kgdb.o gen550_dbg.o
obj-$(CONFIG_SERIAL_TEXT_DEBUG) += gen550_dbg.o
Index: arch/ppc/syslib/m8260_setup.c
===================================================================
--- eed337ef5e9ae7d62caa84b7974a11fddc7f06e0/arch/ppc/syslib/m8260_setup.c (mode:100644 sha1:23ea3f694de2066ec5b324ebedb38b1c027415ce)
+++ /dev/null (tree:072e120576417512a61676af3bfc422268ebfdf9)
@@ -1,264 +0,0 @@
-/*
- * arch/ppc/syslib/m8260_setup.c
- *
- * Copyright (C) 1995 Linus Torvalds
- * Adapted from 'alpha' version by Gary Thomas
- * Modified by Cort Dougan (cort@cs.nmt.edu)
- * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
- * Further modified for generic 8xx and 8260 by Dan.
- */
-
-#include <linux/config.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/initrd.h>
-#include <linux/root_dev.h>
-#include <linux/seq_file.h>
-#include <linux/irq.h>
-
-#include <asm/mmu.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/mpc8260.h>
-#include <asm/immap_cpm2.h>
-#include <asm/machdep.h>
-#include <asm/bootinfo.h>
-#include <asm/time.h>
-
-#include "cpm2_pic.h"
-
-unsigned char __res[sizeof(bd_t)];
-
-extern void cpm2_reset(void);
-extern void m8260_find_bridges(void);
-extern void idma_pci9_init(void);
-
-/* Place-holder for board-specific init */
-void __attribute__ ((weak)) __init
-m82xx_board_setup(void)
-{
-}
-
-static void __init
-m8260_setup_arch(void)
-{
- /* Print out Vendor and Machine info. */
- printk(KERN_INFO "%s %s port\n", CPUINFO_VENDOR, CPUINFO_MACHINE);
-
- /* Reset the Communication Processor Module. */
- cpm2_reset();
-#ifdef CONFIG_8260_PCI9
- /* Initialise IDMA for PCI erratum workaround */
- idma_pci9_init();
-#endif
-#ifdef CONFIG_PCI_8260
- m8260_find_bridges();
-#endif
-#ifdef CONFIG_BLK_DEV_INITRD
- if (initrd_start)
- ROOT_DEV = Root_RAM0;
-#endif
- m82xx_board_setup();
-}
-
-/* The decrementer counts at the system (internal) clock frequency
- * divided by four.
- */
-static void __init
-m8260_calibrate_decr(void)
-{
- bd_t *binfo = (bd_t *)__res;
- int freq, divisor;
-
- freq = binfo->bi_busfreq;
- divisor = 4;
- tb_ticks_per_jiffy = freq / HZ / divisor;
- tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
-}
-
-/* The 8260 has an internal 1-second timer update register that
- * we should use for this purpose.
- */
-static uint rtc_time;
-
-static int
-m8260_set_rtc_time(unsigned long time)
-{
- rtc_time = time;
-
- return(0);
-}
-
-static unsigned long
-m8260_get_rtc_time(void)
-{
- /* Get time from the RTC.
- */
- return((unsigned long)rtc_time);
-}
-
-#ifndef BOOTROM_RESTART_ADDR
-#warning "Using default BOOTROM_RESTART_ADDR!"
-#define BOOTROM_RESTART_ADDR 0xff000104
-#endif
-
-static void
-m8260_restart(char *cmd)
-{
- extern void m8260_gorom(bd_t *bi, uint addr);
- uint startaddr;
-
- /* Most boot roms have a warmstart as the second instruction
- * of the reset vector. If that doesn't work for you, change this
- * or the reboot program to send a proper address.
- */
- startaddr = BOOTROM_RESTART_ADDR;
- if (cmd != NULL) {
- if (!strncmp(cmd, "startaddr=", 10))
- startaddr = simple_strtoul(&cmd[10], NULL, 0);
- }
-
- m8260_gorom((void*)__pa(__res), startaddr);
-}
-
-static void
-m8260_halt(void)
-{
- local_irq_disable();
- while (1);
-}
-
-static void
-m8260_power_off(void)
-{
- m8260_halt();
-}
-
-static int
-m8260_show_cpuinfo(struct seq_file *m)
-{
- bd_t *bp = (bd_t *)__res;
-
- seq_printf(m, "vendor\t\t: %s\n"
- "machine\t\t: %s\n"
- "\n"
- "mem size\t\t: 0x%08x\n"
- "console baud\t\t: %d\n"
- "\n"
- "core clock\t: %u MHz\n"
- "CPM clock\t: %u MHz\n"
- "bus clock\t: %u MHz\n",
- CPUINFO_VENDOR, CPUINFO_MACHINE, bp->bi_memsize,
- bp->bi_baudrate, bp->bi_intfreq / 1000000,
- bp->bi_cpmfreq / 1000000, bp->bi_busfreq / 1000000);
- return 0;
-}
-
-/* Initialize the internal interrupt controller. The number of
- * interrupts supported can vary with the processor type, and the
- * 8260 family can have up to 64.
- * External interrupts can be either edge or level triggered, and
- * need to be initialized by the appropriate driver.
- */
-static void __init
-m8260_init_IRQ(void)
-{
- cpm2_init_IRQ();
-
- /* Initialize the default interrupt mapping priorities,
- * in case the boot rom changed something on us.
- */
- cpm2_immr->im_intctl.ic_siprr = 0x05309770;
-}
-
-/*
- * Same hack as 8xx
- */
-static unsigned long __init
-m8260_find_end_of_memory(void)
-{
- bd_t *binfo = (bd_t *)__res;
-
- return binfo->bi_memsize;
-}
-
-/* Map the IMMR, plus anything else we can cover
- * in that upper space according to the memory controller
- * chip select mapping. Grab another bunch of space
- * below that for stuff we can't cover in the upper.
- */
-static void __init
-m8260_map_io(void)
-{
- uint addr;
-
- /* Map IMMR region to a 256MB BAT */
- addr = (cpm2_immr != NULL) ? (uint)cpm2_immr : CPM_MAP_ADDR;
- io_block_mapping(addr, addr, 0x10000000, _PAGE_IO);
-
- /* Map I/O region to a 256MB BAT */
- io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO);
-}
-
-/* Place-holder for board-specific ppc_md hooking */
-void __attribute__ ((weak)) __init
-m82xx_board_init(void)
-{
-}
-
-/* Inputs:
- * r3 - Optional pointer to a board information structure.
- * r4 - Optional pointer to the physical starting address of the init RAM
- * disk.
- * r5 - Optional pointer to the physical ending address of the init RAM
- * disk.
- * r6 - Optional pointer to the physical starting address of any kernel
- * command-line parameters.
- * r7 - Optional pointer to the physical ending address of any kernel
- * command-line parameters.
- */
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- parse_bootinfo(find_bootinfo());
-
- if ( r3 )
- memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
-
-#ifdef CONFIG_BLK_DEV_INITRD
- /* take care of initrd if we have one */
- if ( r4 ) {
- initrd_start = r4 + KERNELBASE;
- initrd_end = r5 + KERNELBASE;
- }
-#endif /* CONFIG_BLK_DEV_INITRD */
- /* take care of cmd line */
- if ( r6 ) {
- *(char *)(r7+KERNELBASE) = 0;
- strcpy(cmd_line, (char *)(r6+KERNELBASE));
- }
-
- ppc_md.setup_arch = m8260_setup_arch;
- ppc_md.show_cpuinfo = m8260_show_cpuinfo;
- ppc_md.init_IRQ = m8260_init_IRQ;
- ppc_md.get_irq = cpm2_get_irq;
-
- ppc_md.restart = m8260_restart;
- ppc_md.power_off = m8260_power_off;
- ppc_md.halt = m8260_halt;
-
- ppc_md.set_rtc_time = m8260_set_rtc_time;
- ppc_md.get_rtc_time = m8260_get_rtc_time;
- ppc_md.calibrate_decr = m8260_calibrate_decr;
-
- ppc_md.find_end_of_memory = m8260_find_end_of_memory;
- ppc_md.setup_io_mappings = m8260_map_io;
-
- /* Call back for board-specific settings and overrides. */
- m82xx_board_init();
-}
Index: arch/ppc/syslib/mpc82xx_devices.c
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/syslib/mpc82xx_devices.c (mode:100644 sha1:42501a5f121d8524576162eb03f3bc945bf19636)
@@ -0,0 +1,121 @@
+/*
+ * arch/ppc/syslib/mpc82xx_devices.c
+ *
+ * MPC82xx Device descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <linux/fs_enet_pd.h>
+#include <asm/mpc8260.h>
+#include <asm/cpm2.h>
+#include <asm/immap_cpm2.h>
+#include <asm/irq.h>
+#include <asm/ppc_sys.h>
+#include <asm/ppcboot.h>
+
+
+struct platform_device ppc_sys_platform_devices[] = {
+ [MPC82xx_FCC1] = {
+ .name = FS_ENET_NAME,
+ .id = 1,
+ .num_resources = 5,
+ .resource = (struct resource[]) {
+ {
+ .name = "fcc_regs",
+ .start = 0x11300,
+ .end = 0x1131f,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_regs_c",
+ .start = 0x11380,
+ .end = 0x1139f,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_pram",
+ .start = 0x8400,
+ .end = 0x84ff,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_mem",
+ .start = 0x9000,
+ .end = 0x907f,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "interrupt",
+ .start = SIU_INT_FCC1,
+ .end = SIU_INT_FCC1,
+ .flags = IORESOURCE_IRQ,
+ },
+ },
+ },
+ [MPC82xx_FCC2] = {
+ .name = FS_ENET_NAME,
+ .id = 2,
+ .num_resources = 5,
+ .resource = (struct resource[]) {
+ {
+ .name = "fcc_regs",
+ .start = 0x11320,
+ .end = 0x1133f,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_regs_c",
+ .start = 0x113a0,
+ .end = 0x113bf,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_pram",
+ .start = 0x8500,
+ .end = 0x85ff,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "fcc_mem",
+ .start = 0x9080,
+ .end = 0x90ff,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "interrupt",
+ .start = SIU_INT_FCC2,
+ .end = SIU_INT_FCC2,
+ .flags = IORESOURCE_IRQ,
+ },
+ },
+ }
+};
+
+static int __init mach_mpc82xx_fixup(struct platform_device *pdev)
+{
+ ppc_sys_fixup_mem_resource(pdev, CPM_MAP_ADDR);
+ return 0;
+}
+
+static int __init mach_mpc82xx_init(void)
+{
+ if (ppc_md.progress)
+ ppc_md.progress("mach_mpc82xx_init:enter", 0);
+ ppc_sys_device_fixup = mach_mpc82xx_fixup;
+ return 0;
+}
+
+postcore_initcall(mach_mpc82xx_init);
Index: arch/ppc/syslib/mpc82xx_sys.c
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/arch/ppc/syslib/mpc82xx_sys.c (mode:100644 sha1:b793dd75df5055157e804e892223920c03641a73)
@@ -0,0 +1,42 @@
+/*
+ * arch/ppc/syslib/mpc82xx_devices.c
+ *
+ * MPC82xx System descriptions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+
+#include <asm/ppc_sys.h>
+
+
+struct ppc_sys_spec *cur_ppc_sys_spec;
+struct ppc_sys_spec ppc_sys_specs[] = {
+
+ {
+ .ppc_sys_name = "MPC8272ads",
+ .mask = 0xFFFF0000,
+ .value = 0x0c100000,
+ .num_devices = 2,
+ .device_list = (enum ppc_sys_devices[])
+ {
+ MPC82xx_FCC1,
+ MPC82xx_FCC2,
+ },
+ },
+ { /* default match */
+ .ppc_sys_name = "",
+ .mask = 0x00000000,
+ .value = 0x00000000,
+ },
+};
Index: include/asm-ppc/mpc8260.h
===================================================================
--- eed337ef5e9ae7d62caa84b7974a11fddc7f06e0/include/asm-ppc/mpc8260.h (mode:100644 sha1:d820894e59916a4c491b8bdd0312830acec228a9)
+++ 072e120576417512a61676af3bfc422268ebfdf9/include/asm-ppc/mpc8260.h (mode:100644 sha1:a9c046b16be566e215143fb044e17a233a1c4194)
@@ -74,6 +74,11 @@
extern unsigned char __res[];
#endif
+enum ppc_sys_devices {
+ MPC82xx_FCC1,
+ MPC82xx_FCC2,
+};
+
#endif /* CONFIG_8260 */
#endif /* !__ASM_PPC_MPC8260_H__ */
#endif /* __KERNEL__ */
Index: include/asm-ppc/ppc_sys.h
===================================================================
--- eed337ef5e9ae7d62caa84b7974a11fddc7f06e0/include/asm-ppc/ppc_sys.h (mode:100644 sha1:24b991c427694d425225c2cacde01b5bc469ed0a)
+++ 072e120576417512a61676af3bfc422268ebfdf9/include/asm-ppc/ppc_sys.h (mode:100644 sha1:2a7636166c83f1187631cbfe5aa1003c691d2d2b)
@@ -27,6 +27,8 @@
#include <asm/mpc85xx.h>
#elif defined(CONFIG_PPC_MPC52xx)
#include <asm/mpc52xx.h>
+#elif defined(CONFIG_8260)
+#include <asm/mpc8260.h>
#else
#error "need definition of ppc_sys_devices"
#endif
Index: include/linux/fs_enet_pd.h
===================================================================
--- /dev/null (tree:eed337ef5e9ae7d62caa84b7974a11fddc7f06e0)
+++ 072e120576417512a61676af3bfc422268ebfdf9/include/linux/fs_enet_pd.h (mode:100644 sha1:314b72e4dab21c36f431c2c2950fee8586dcce8e)
@@ -0,0 +1,107 @@
+#ifndef FS_ENET_PD_H
+#define FS_ENET_PD_H
+
+#include <asm/types.h>
+
+#define FS_ENET_NAME "fs_enet"
+
+enum fs_id {
+ fsid_fec1,
+ fsid_fec2,
+ fsid_fcc1,
+ fsid_fcc2,
+ fsid_fcc3,
+ fsid_scc1,
+ fsid_scc2,
+ fsid_scc3,
+ fsid_scc4,
+};
+
+#define FS_MAX_INDEX 9
+
+static inline int fs_get_fec_index(enum fs_id id)
+{
+ if (id >= fsid_fec1 && id <= fsid_fec2)
+ return id - fsid_fec1;
+ return -1;
+}
+
+static inline int fs_get_fcc_index(enum fs_id id)
+{
+ if (id >= fsid_fcc1 && id <= fsid_fcc3)
+ return id - fsid_fcc1;
+ return -1;
+}
+
+static inline int fs_get_scc_index(enum fs_id id)
+{
+ if (id >= fsid_scc1 && id <= fsid_scc4)
+ return id - fsid_scc1;
+ return -1;
+}
+
+enum fs_mii_method {
+ fsmii_fixed,
+ fsmii_fec,
+ fsmii_bitbang,
+};
+
+enum fs_ioport {
+ fsiop_porta,
+ fsiop_portb,
+ fsiop_portc,
+ fsiop_portd,
+ fsiop_porte,
+};
+
+struct fs_mii_bus_info {
+ int method; /* mii method */
+ int id; /* the id of the mii_bus */
+ union {
+ struct {
+ int duplex;
+ int speed;
+ } fixed;
+
+ struct {
+ /* nothing */
+ } fec;
+
+ struct {
+ int mdio_port; /* port & bit for MDIO */
+ int mdio_bit;
+ int mdc_port; /* port & bit for MDC */
+ int mdc_bit;
+ int delay; /* delay in us */
+ } bitbang;
+ } i;
+};
+
+struct fs_platform_info {
+ /* device specific information */
+ int fs_no; /* controller index */
+
+ u32 cp_page; /* CPM page */
+ u32 cp_block; /* CPM sblock */
+
+ u32 clk_trx; /* some stuff for pins & mux configuration*/
+ u32 clk_route;
+ u32 clk_mask;
+
+ u32 device_flags;
+
+ int phy_addr; /* the phy address (-1 no phy) */
+ int phy_irq; /* the phy irq (if it exists) */
+
+ const struct fs_mii_bus_info *bus_info;
+
+ int rx_ring, tx_ring; /* number of buffers on rx */
+ __u8 macaddr[6]; /* mac address */
+ int rx_copybreak; /* limit we copy small frames */
+ int use_napi; /* use NAPI */
+ int napi_weight; /* NAPI weight */
+
+ int use_rmii; /* use RMII */
+};
+
+#endif
\f
!-------------------------------------------------------------flip-
^ permalink raw reply
* Re: Missing m8260_cpm_dpfree()
From: Alex Zeffertt @ 2005-06-02 13:56 UTC (permalink / raw)
To: linuxppc-embedded
In-Reply-To: <20050518102814.4f8dc376.ajz@cambridgebroadband.com>
[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]
Hi,
A while ago I posted a patch which added the m8260_cpm_dpfree()
function. I've just noticed a bug in this which is fixed in the
attached patch.
Alex
On Wed, 18 May 2005 10:28:14 +0100
Alex Zeffertt <ajz@cambridgebroadband.com> wrote:
> Hi,
>
> I'm replying to my own message. I've got around to porting the 8xx
> version of ...cpm_dpfree() to the 8260 now. I've attached the patch
> on the off chance anyone else might want it. The patch is against the
> 2005-03-06 version of denx's linuxppc_2_4_devel, which is a 2.4.25
> kernel.
>
> Alex
>
> On Mon, 16 May 2005 16:15:03 +0100
> Alex Zeffertt <ajz@cambridgebroadband.com> wrote:
>
> > Hi all,
> >
> > I have a question about the MPC8260 dual port RAM allocation
> > routines.
> >
> > In arch/ppc/8260_io/commproc.c this is a m8260_cpm_dpalloc()
> > routine, but the m8260_cpm_dpfree() routine is missing. Does
> > anybody know where I can find this?
> >
> > I am using denx's linuxppc_2_4_devel tree from 2005-03-06.
> >
> > TIA,
> >
> > Alex
>
[-- Attachment #2: linux-m8260_cpm_dpfree.patch-2 --]
[-- Type: application/octet-stream, Size: 7423 bytes --]
--- linux-2.4.25.orig/arch/ppc/8260_io/commproc.c 2003-10-30 00:32:09.000000000 +0000
+++ linux-2.4.25/arch/ppc/8260_io/commproc.c 2005-06-02 14:47:16.000000000 +0100
@@ -29,12 +29,264 @@
#include <asm/immap_8260.h>
#include <asm/cpm_8260.h>
+#define DPFREE
+
+#ifdef DPFREE
+typedef struct cpm_dpalloc_entry_s {
+ u_short start_addr;
+ u_short retloc; /* This is start_addr + alignment offset: only valid in alloc list */
+ u_short size;
+ struct cpm_dpalloc_entry_s * next_entr;
+} cpm_dpalloc_entry_t;
+
+static void cpm_dpalloc_init(void);
+static void cpm_dpalloc_data_init(cpm_dpalloc_entry_t *);
+static int cpm_dpalloc_cl(cpm_dpalloc_entry_t *);
+static int cpm_dpalloc_rem(cpm_dpalloc_entry_t **, cpm_dpalloc_entry_t *);
+static void cpm_dpalloc_ins(cpm_dpalloc_entry_t **, cpm_dpalloc_entry_t *);
+# define CPM_DPALLOC_COUNT (CPM_DATAONLY_SIZE / sizeof(cbd_t) + 1)
+/* Dynamic lists of allocated and free DPRAM */
+static cpm_dpalloc_entry_t *cpm_dpalloc_free;
+static cpm_dpalloc_entry_t *cpm_dpalloc_alloc;
+static cpm_dpalloc_entry_t cpm_dpalloc_list[CPM_DPALLOC_COUNT];
+#else
static uint dp_alloc_base; /* Starting offset in DP ram */
static uint dp_alloc_top; /* Max offset + 1 */
+#endif
static uint host_buffer; /* One page of host buffer */
static uint host_end; /* end + 1 */
cpm8260_t *cpmp; /* Pointer to comm processor space */
+#ifdef DPFREE
+/* Initialize dynamic lists
+ */
+static void cpm_dpalloc_init(void)
+{
+ int i;
+
+ cpm_dpalloc_free = cpm_dpalloc_list;
+ cpm_dpalloc_free->start_addr = CPM_DATAONLY_BASE;
+ cpm_dpalloc_free->size = CPM_DATAONLY_SIZE;
+ cpm_dpalloc_free->next_entr = NULL;
+ cpm_dpalloc_alloc = NULL;
+
+ for(i = 1; i <= CPM_DPALLOC_COUNT; i++) {
+ cpm_dpalloc_data_init (cpm_dpalloc_list + i);
+ }
+}
+
+/* Initialize element in list of DPRAM
+ */
+static void cpm_dpalloc_data_init(cpm_dpalloc_entry_t * ptr)
+{
+ ptr->retloc = ptr->start_addr = 0;
+ ptr->size = 0;
+ ptr->next_entr = NULL;
+}
+
+static int cpm_dpalloc_cl(cpm_dpalloc_entry_t * head)
+{
+ cpm_dpalloc_entry_t * curr;
+ cpm_dpalloc_entry_t * next;
+ int retloc;
+
+ curr = head;
+ retloc = -1;
+
+ if (curr) {
+ retloc = 0;
+
+ while ((next = curr->next_entr)) {
+ if (curr->start_addr + curr->size == next->start_addr) {
+ curr->size = curr->size + next->size;
+ curr->next_entr = next->next_entr;
+ cpm_dpalloc_data_init(next);
+ } else {
+ curr = next;
+ }
+ }
+ }
+
+ return retloc;
+}
+
+/* Remove element from dynamic list of DPRAM
+ */
+static int cpm_dpalloc_rem(cpm_dpalloc_entry_t ** head, cpm_dpalloc_entry_t * ptr)
+{
+ cpm_dpalloc_entry_t * prev;
+ cpm_dpalloc_entry_t * curr;
+ int retloc;
+
+ retloc = -1;
+ for (prev = NULL , curr = *head;
+ curr != NULL && ptr != curr;
+ prev = curr , curr = curr->next_entr)
+ /* EMPTY */ ;
+
+ if (curr) {
+ if (prev) {
+ prev->next_entr = curr->next_entr;
+ } else {
+ *head = curr->next_entr;
+ }
+ retloc = 0;
+ }
+
+ return retloc;
+}
+
+/* Insert element in dynamic list of DPRAM
+ */
+static void cpm_dpalloc_ins(cpm_dpalloc_entry_t ** head, cpm_dpalloc_entry_t * ptr)
+{
+ cpm_dpalloc_entry_t * prev;
+ cpm_dpalloc_entry_t * curr;
+
+ for (prev = NULL , curr = *head;
+ curr != NULL && ptr->start_addr >= curr->start_addr;
+ prev = curr , curr = curr->next_entr)
+ /* EMPTY */ ;
+
+ ptr->next_entr = curr;
+
+ if (prev) {
+ prev->next_entr = ptr;
+ } else {
+ *head = ptr;
+ }
+}
+/* Allocate some memory from the dual ported ram. We may want to
+ * enforce alignment restrictions, but right now everyone is a good
+ * citizen.
+ */
+uint m8260_cpm_dpalloc(uint size, uint align)
+{
+ cpm_dpalloc_entry_t * new_el;
+ cpm_dpalloc_entry_t * p;
+ cpm_dpalloc_entry_t * p1;
+ uint retloc;
+ u_short max;
+ unsigned long flags;
+ int i;
+ uint align_mask;
+ uint off;
+
+ size = (size + 7) & ~7;
+ align_mask = align - 1;
+ max = CPM_DATAONLY_SIZE;
+ retloc = 0;
+ new_el = NULL;
+
+ if (size == 0) goto DONE;
+
+ save_flags(flags);
+ cli();
+
+ /* Find free area in DPRAM
+ */
+ for (p = cpm_dpalloc_free; p != NULL; p = p->next_entr) {
+ if (p->size <= max) {
+ off = ((p->start_addr + align_mask) & (~align_mask)) - p->start_addr;
+ if (p->size >= size + off) {
+ new_el = p;
+ max = p->size;
+ retloc = p->start_addr + off;
+ }
+ }
+ }
+
+ if (new_el == NULL) goto DONE1;
+
+ /* Insert new element in the list of allocated DPRAM
+ */
+ p1 = cpm_dpalloc_list;
+ p = NULL;
+ i = 0;
+ while (i < CPM_DPALLOC_COUNT) {
+ if (p1->start_addr == 0 && !p1->size && !p1->next_entr) {
+ p = p1;
+ break;
+ }
+ i ++;
+ p1 ++;
+ }
+
+ if (p == NULL) {
+ panic ("m8xx_cpm_dpalloc: INTERNAL ERROR\n");
+ }
+
+ off = retloc - new_el->start_addr;
+
+ p->start_addr = new_el->start_addr;
+ p->retloc = retloc;
+ p->size = size + off;
+
+ if (new_el->size > (size+off)) {
+ new_el->size -= (size+off);
+ new_el->start_addr += (size+off);
+ cpm_dpalloc_ins(&cpm_dpalloc_alloc, p);
+ } else {
+ cpm_dpalloc_ins(&cpm_dpalloc_alloc, p);
+ i = cpm_dpalloc_rem(&cpm_dpalloc_free, new_el);
+
+ if ( i == -1) {
+ panic ("m8xx_cpm_dpalloc: INTERNAL ERROR\n");
+ }
+
+ cpm_dpalloc_data_init(new_el);
+ }
+
+ DONE1:
+ restore_flags(flags);
+ DONE:
+ return retloc;
+}
+
+int m8260_cpm_dpfree(uint retloc)
+{
+ cpm_dpalloc_entry_t * r;
+ int retval;
+ unsigned long flags;
+
+ retval = -1;
+
+ if ((retloc < CPM_DATAONLY_BASE) ||
+ (retloc > CPM_DATAONLY_SIZE + CPM_DATAONLY_BASE)) {
+ goto DONE;
+ }
+
+ save_flags(flags);
+ cli();
+
+ for (r = cpm_dpalloc_alloc;
+ (r != NULL) && (r->retloc != retloc);
+ r = r->next_entr)
+ /* EMPTY */ ;
+
+ if (r) {
+ retval = cpm_dpalloc_rem(&cpm_dpalloc_alloc, r);
+
+ if (retval == -1) {
+ panic("m8xx_cpm_dpfree: INTERNAL ERROR\n");
+ }
+ cpm_dpalloc_ins(&cpm_dpalloc_free, r);
+ retval = cpm_dpalloc_cl(cpm_dpalloc_free);
+
+ if (retval == -1) {
+ panic("m8xx_cpm_dpfree: INTERNAL ERROR\n");
+ }
+ retval = 0;
+ } else {
+ printk(KERN_ERR "m8xx_cpm_dpfree: address not found in alloc list\n");
+ }
+
+ restore_flags(flags);
+DONE:
+ return retval;
+}
+#endif /* DPFREE */
+
/* We allocate this here because it is used almost exclusively for
* the communication processor devices.
*/
@@ -50,11 +302,14 @@
immr = imp = (volatile immap_t *)IMAP_ADDR;
commproc = &imp->im_cpm;
+#ifdef DPFREE
+ cpm_dpalloc_init();
+#else
/* Reclaim the DP memory for our use.
*/
dp_alloc_base = CPM_DATAONLY_BASE;
dp_alloc_top = dp_alloc_base + CPM_DATAONLY_SIZE;
-
+#endif
/* Set the host page for allocation.
*/
host_buffer =
@@ -68,6 +323,7 @@
cpmp = (cpm8260_t *)commproc;
}
+#ifndef DPFREE
/* Allocate some memory from the dual ported ram.
* To help protocols with object alignment restrictions, we do that
* if they ask.
@@ -95,6 +351,12 @@
return(retloc);
}
+int m8260_cpm_dpfree(uint start_addr)
+{
+ printk(KERN_ERR "%s() not implemented\n", __FUNCTION__);
+ return -1;
+}
+#endif /*ifndef DPFREE*/
/* We also own one page of host buffer space for the allocation of
* UART "fifos" and the like.
^ permalink raw reply
* Re: ppc32: Rework power management take #3
From: Wolfram Quester @ 2005-06-02 13:05 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, debian-powerpc@lists.debian.org
In-Reply-To: <3db27390050530145939d260e4@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]
Hi,
On Mon, May 30, 2005 at 11:59:14PM +0200, Mickael Royer wrote:
> Hi Ben
>
> > Ok, the patch is now getting "good enough" for wider testing. It applies
> > on current "git" tree (or 2.6.12-rc6 when/if that is ever released).
>
> I have just tested your patch with the 2.5.12-rc5-git5 on the new powerbook 12".
> And yes, the suspend to disk works very well, even if X is running (I
> report my problem with X and the suspend to disk with a 2.6.12-rc4 in
> another discussion).
> It is really good.
>
> Thanks for your good job Ben.
>
> Mickael
>
> On 5/30/05, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> > Ok, the patch is now getting "good enough" for wider testing. It applies
> > on current "git" tree (or 2.6.12-rc6 when/if that is ever released). It
> > requires one other patch to be applied first:
> >
> > http://gate.crashing.org/~benh/ppc32-remove-macserial.diff
> >
> > The PM patch itself can be found at:
> >
> > http://gate.crashing.org/~benh/ppc32-rework-pm.diff
> >
> > This patch completely reworks both suspend-to-ram and suspend-to-disk
> > support on PowerMac:
[...snip...]
Today I applied the two mentioned patches to rc5-git6. There were quite
a lot of offsets and one time fuzz 2 (hunk 10 in via-pm.c). But still I
get a freeze on my PowerBook6,2 (12", 1Ghz from Dec. 2004) when I
suspend to disk from X. If I suspend from tty1 the first time, the
following suspends work well even from X.
Thanks for your work,
Wolfi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* RE : RE : copy_from_user( ) problem...help
From: Garcia Jérémie @ 2005-06-02 13:00 UTC (permalink / raw)
To: Jeff.Fellin; +Cc: linuxppc-dev
Ok Jeff. Thanks a lot for your help and let me congratulate you for your =
answer's quality.
Really you're a treasure for people like me.=20
Nevertheless, I tried another way using ioctl() and that works very well =
and with your explanations
I understand now why. So it's all process context related.
Have a nice day and thks again, sincerly
J=E9r=E9mie
-------- Message d'origine--------
De: Jeff.Fellin@rflelect.com [mailto:Jeff.Fellin@rflelect.com]
Date: jeu. 02/06/2005 14:21
=C0: Garcia J=E9r=E9mie
Objet : RE : copy_from_user( ) problem...help
=20
Jeff Fellin
RFL Electronics
Jeff.Fellin@rflelect.com
973 334-3100, x 327
=
=20
Garcia J=E9r=E9mie =
=20
<GARCIAJ@3il.fr> To: =
<Jeff.Fellin@rflelect.com> =20
cc: =
=20
06/02/2005 04:27 Subject: RE : =
copy_from_user( ) problem...help =20
=
=20
=
=20
I'm sorry to be such a newbie in Linux, but I don't understand why the
problem
would be process-related.
As described in Linux Kernel Development by Robert Love under =
Process
Management, section
Process Context: When a process a system call it enters kernel =
state.
At this point the
kernel is said to be "executing on behalf of the user process" and =
is
in process context.
The kernel is not a self-executing process. It only executes on
interrupts or user process
requests. When executing on user process request, the only visible
user space is the user
address space of the process invoking the system call. Not all =
user
processes are
addressable.
Cause the copy_from_user() just needs an user-space address whatever is =
the
process. Isn't it
what I do here?
Yes, it needs a user-space address, at the address is dereferenced
using the current processes address mapping. In your example =
of
a small process all of it's addresses
would probably exist in any other process. However, for the kernel =
to
reference the
address space of a process not executing the system call requires
finding the page
table of the process and then decoding the address to the physical
address, mapping that
address into the kernel, and copying the data into the kernel.
So how would that kernel routine be usable?
The routine is usable, but only within the context of the current
process, not an
arbitary process. See Chapter 4, System calls for more reasons.
Could you give me a little more explanations? And could you tell me if =
what
I want to do
is possible using that way and what I missed?
I hope the above and references are sufficient explanation. There =
is
no possible method
to pass addresses from different processes into the kernel. You =
must
always obey the
Process Context concept. Others have suggested methods to resolve
this issue via sysfs,
which is also described in Rober Love's book. I suggest you =
purchase
this and read it
before continuing.
-------- Message d'origine--------
De: Jeff.Fellin@rflelect.com [mailto:Jeff.Fellin@rflelect.com]
Date: mer. 01/06/2005 16:48
=C0: Garcia J=E9r=E9mie
Objet : Re: copy_from_user( ) problem...help
Jeremie,
The Address you give is to the user process to your kernel is an address =
in
the insmod
process, which is the actual user process your module is referencing. =
You
can verify this
by printing out the process id's in your user command, and the
current->pid, in your module.
They should be different, and the current->pid in your module should be =
the
PID of the insmod
command.
Jeff Felline insmod
RFL Electronics
Jeff.Fellin@rflelect.com
973 334-3100, x 327
Garcia J=E9r=E9mie
<GARCIAJ@3il.fr> To:
<linuxppc-dev@ozlabs.org>
Sent by: cc:
linuxppc-dev-bounces Subject: =
copy_from_user(
) problem...help
@ozlabs.org
e insmod (you c
06/01/2005 10:00
Hi everybody,
I'm tryin to write some device drivers modules in order to manage some =
of
our devices of our ppc405EP based board.
I read the Allessandro Rubini book (Linux Kernel device drivers) in =
order
to help me.
Before going on difficult stuff, I'd like to make some basic training =
and
experiments.
What I want to do seems to be very easy (but...):
- a user space programm has a global structure and contains an integer =
and
a char
- the user space programm loads the module with a parameter: the =
structure
address
- during the init_module(),I check that the address can be accessed in =
R/W
mode with the access_ok()
- the module copies the user structure in its own context and prints =
the
values retreived
So, it's supposed to be a very easy operation, but something goes wrong.
Could someone give me a clue cause
I read it again and again and I don't get what's the matter. Here is the
code:
/************************************************************************=
******/
/* USER SPACE PROG
*/
/************************************************************************=
******/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
typedef struct une_structure
{
int un_entier;
char un_char;
}UNE_STRUCTURE;
UNE_STRUCTURE my_structure;
void main(void)
{
char buff[100];
/* Init of the structure */
my_structure.un_entier =3D 5;
my_structure.un_char =3D 'a';
/* Build the shell command to load the module */
sprintf(buff,"insmod -q ./un_module.o addr=3D%p",&my_structure);
/* Print the shell command that loads the module */
printf("\nCommmande : ");
puts(buff);
/* Load the module*/
system(buff);
sleep(2);
/* Remove the module */
system("rmmod un_module");
}
/************************************************************************=
/
/* KERNEL MODULE =
*/
/************************************************************************=
/
[...]
typedef struct une_structure
{
int un_entier;
char un_char;
}UNE_STRUCTURE;
UNE_STRUCTURE *addr =3D 0x0; /* default value */
MODULE_PARM(addr,"l"); /* get the address of the user space =
structure
given in argument at insmod()
*/
int init_module(void)
{
int rc;
UNE_STRUCTURE * my_structure;
printk("Address of the user structure : %d\n",(int)addr);
/* Alloc space for ou structure */
my_structure =3D kmalloc(sizeof(UNE_STRUCTURE),GFP_DMA);
if(my_structure=3D=3DNULL)
{
printk("Kernel memory allocation failed!\n");
return -1;
}
else
printk("Kernel memory allocation succeeded!\n");
rc =3D access_ok(VERIFY_READ,(void *)addr,sizeof(UNE_STRUCTURE));
if(rc !=3D 0)
{
rc =3D access_ok(VERIFY_WRITE,(void *)addr,sizeof(UNE_STRUCTURE));
if(rc !=3D 0)
{
rc =3D copy_from_user(my_structure,(void
*)addr,sizeof(UNE_STRUCTURE));
if(rc)
printk("Error in copy_from_user, rc=3D%d\n",rc);
else
{
printk("Values of the retreived user-space structure 's
fields:\n");
printk("\t -> un_entier =3D %d \n",my_structure->un_entier);
printk("\t -> un_unsigned_char =3D %c =
\n",my_structure->un_char);
}
}
else
{
printk("Erreur in accessing addr in WRITE mode\n");
return -1;
}
}
else
{
printk("Erreur in accessing addr in READ mode\n");
return -1;
}
return 0;
}
/************************************************************************=
***/
/* EXECUTION RESULTS
*/
/************************************************************************=
***/
root@10.16.9.232:/home/testDir# ./une_appli.exe
[USER-SPACE]Commmande : insmod -q ./un_module.o addr=3D0x10010a74
[KERN-SPACE]Address of the user structure : 268503668 // =
is
the same if converted in hexa
[KERN-SPACE]Kernel memory allocation succeeded!
[KERN-SPACE]Values of the retreived user-space structure 's fields:
-> un_entier =3D -1857486844 //
weird result and !=3D 5
-> un_unsigned_char =3D . //
weird result and !=3D 'a'
[KERN-SPACE]Now releasing the module...
As you can see, I don't really retreived the user-space structure in the
kernel. Is it an address problem?
If I understood well, no ioremap is needded here cause the address given =
in
argument of insmod is from MMU.
So what's the problem ; I really think that I'm dealing with a wrong
address.
Please help a newbie that would like to understand... Tks for your =
precious
help.
Jeremie
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev
^ permalink raw reply
* RE: Newbie question on Linux-PPC
From: Srivatsan CR @ 2005-06-02 7:41 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
Hi all,
Thanks everyone for the time. It's done and I have it working.
I have another question regarding MAC address in Linux. I had ported
U-boot onto our customized board (MPC8280 based). It is working fine. I am
also able to boot a Linux Kernel. The Kernel version is Linux-2.4.20 .
We set the MAC address for the board in U-boot as 00:FD:11:01:01:01. But
when the Linux Kernel boots it takes the MAC as 00:FD:81:01:01:01.
I have confirmed that the U-boot passes the MAC address properly to the
Linux Kernel properly. Can anyone guide me to where to look out for the
issue stated above in the Linux code?
Thanks everyone for the time.
With Regards,
C.R.Srivatsan
[-- Attachment #2: Type: text/html, Size: 7455 bytes --]
^ permalink raw reply
* Re: [RFC] handle access to non-present IO ports on 8xx
From: Pantelis Antoniou @ 2005-06-02 7:04 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linux-ppc-embedded
In-Reply-To: <1117680392.31082.16.camel@gaston>
Benjamin Herrenschmidt wrote:
> On Wed, 2005-06-01 at 13:50 -0300, Marcelo Tosatti wrote:
>
> Hrm... removing a PCMCIA card triggers mchecks ? that is bad... With
> "proper" PCMCIA controllers, those are swallowed properly when the card
> is removed. The eating of the machine check is a bit too hackish to my
> taste... Better is to "not do that" by making sure the legacy crap isn't
> trying to tap unexisting ports, but then, if PCMCIA is also a
> problem...
>
8xx is not proper in any way whatsoever :)
There's no way to fix this thing with simple software hacks.
For example take a PCMCIA driver that's minding it's own businees,
when someone yanks the card out.
cli()
...
inb(xxx)
...
<----- card is yanked here
...
inb(yyy)
...
<----- MCE here
sti()
>
>>1) why does the current PowerMac version covers only inb() and not outb() ?
>>I had to add outb() exception table entries for 8xx.
>
>
> Not sure, maybe historical loss ? :) You should CC paulus
>
>
>>2) Is the same wanted for other embedded PPC's?
>
>
> It's up to you. It slows down those IOs, but on the other hand, inX/outX
> aren't supposed to be very common anymore, at least not with "fast"
> devices, and the IO itself is usually an order of magnitude slower than
> doing those syncs...
>
Fast ISA I/O. :)
>
>>3) How to make the misc.S exception entries and additional instructions
>>selectable only on the platform who need it? #ifdef does not sound
>>a good idea.
I wouldn't mind...
>>
>>Nevermind the "#ifdef CONFIG_ALL_PPC" crap - that needs to be done
>>properly.
>>
>>
Regards
Pantelis
P.S. Good job marcello :)
^ permalink raw reply
* Re: Booting the linux-ppc64 kernel & flattened device tree v0.4
From: David Gibson @ 2005-06-02 7:09 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: linuxppc-dev list, u-boot-users, linuxppc64-dev,
linuxppc-embedded
In-Reply-To: <1117614390.19020.24.camel@gaston>
On Wed, Jun 01, 2005 at 06:26:30PM +1000, Benjamin Herrenschmidt wrote:
> DO NOT REPLY TO ALL LISTS PLEASE ! (and CC me on replies).
>
> Here's the fourth version of my document along with new kernel patches
> for the new improved flattened format, and the first release of the
> device-tree "compiler" tool. The patches will be posted as a reply to
> this email. The compiler, dtc, can be downloaded, the URL is in the
> document.
[snip]
> IV - "dtc", the device tree compiler
> ====================================
>
> dtc source code can be found at
> <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
I've just updated the dtc tarball with a new version. Notable
changes:
- Corrected comment parsing
- Corrected handling of #address-cells, #size-cells properties
- Input from device tree blobs should actually work now
- Corrected autogeneration of "name" properties in blob/asm
output version < 0x10
- Added a TODO list
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/people/dgibson
^ permalink raw reply
* Re: Tiny patch for arch/ppc/kernel/cputable.c to properly support the IBM PowerPC 750CXe rev 3.1
From: Benjamin Herrenschmidt @ 2005-06-02 5:41 UTC (permalink / raw)
To: Nicolas DET; +Cc: linuxppc-dev
In-Reply-To: <20050602053107.111887000086@mwinf0701.wanadoo.fr>
On Thu, 2005-06-02 at 07:29 +0100, Nicolas DET wrote:
> Hello Benjamin,
>
> On 01/06/2005, you wrote:
> > On Wed, 2005-06-01 at 19:14 +0100, Nicolas DET wrote:
> >> Hello,
> >>
> >> You can find enclosed a small patch to properly support the 750 CXe rev
> >> 3.1. Indeed, the current kernel (2.6.11.11) only supports rev 2.1 and
> >> ignores 3.1
> >>
> >> It's a tiny patch: it only add an entry in the table with the correct
> >> PVR and name. Others values has been copied from 750CXe rev 2.1.
> >>
> >> I succesfully patched & compiled a vanila 2.6.11.11 from kernel.org.
>
> > Is it needed ? I have it in my local tree and never actuall remembered
> > to actually send it :) In general, that kind of entries are really only
> > needed when there is a feature change...
>
> .cpu_features is exactly the same compare to 745/755 (750CXe 3.1, PVR 0008
> 3311, was probed as 745/755). However, there is a small difference: It now
> calls __setup_cpu_750cx instead of __setup_cpu_750.
> This end up calling setup_750cx which looks like to disable NAP.
Ah, yes, for some PLL configurations... if the CXe is not affected by
this bug, it should probably avoid that "fixup" then...
> Well, I did not notice anything before and after the patch. It's more
> 'comsetic': cpuinfo shows the correct cpu name. :-)
>
> Regards
^ permalink raw reply
* Re: Tiny patch for arch/ppc/kernel/cputable.c to properly support the IBM PowerPC 750CXe rev 3.1
From: Nicolas DET @ 2005-06-02 6:29 UTC (permalink / raw)
To: Benjamin Herrenschmidt, linuxppc-dev
In-Reply-To: <1117664786.19020.81.camel@gaston>
Hello Benjamin,
On 01/06/2005, you wrote:
> On Wed, 2005-06-01 at 19:14 +0100, Nicolas DET wrote:
>> Hello,
>>
>> You can find enclosed a small patch to properly support the 750 CXe rev
>> 3.1. Indeed, the current kernel (2.6.11.11) only supports rev 2.1 and
>> ignores 3.1
>>
>> It's a tiny patch: it only add an entry in the table with the correct
>> PVR and name. Others values has been copied from 750CXe rev 2.1.
>>
>> I succesfully patched & compiled a vanila 2.6.11.11 from kernel.org.
> Is it needed ? I have it in my local tree and never actuall remembered
> to actually send it :) In general, that kind of entries are really only
> needed when there is a feature change...
.cpu_features is exactly the same compare to 745/755 (750CXe 3.1, PVR 0008
3311, was probed as 745/755). However, there is a small difference: It now
calls __setup_cpu_750cx instead of __setup_cpu_750.
This end up calling setup_750cx which looks like to disable NAP.
Well, I did not notice anything before and after the patch. It's more
'comsetic': cpuinfo shows the correct cpu name. :-)
Regards
--
Nicolas DET
MorphOS & Linux developer
^ permalink raw reply
* Re: [RFC] handle access to non-present IO ports on 8xx
From: Benjamin Herrenschmidt @ 2005-06-02 2:46 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: linux-ppc-embedded
In-Reply-To: <20050601165054.GA2607@logos.cnet>
On Wed, 2005-06-01 at 13:50 -0300, Marcelo Tosatti wrote:
Hrm... removing a PCMCIA card triggers mchecks ? that is bad... With
"proper" PCMCIA controllers, those are swallowed properly when the card
is removed. The eating of the machine check is a bit too hackish to my
taste... Better is to "not do that" by making sure the legacy crap isn't
trying to tap unexisting ports, but then, if PCMCIA is also a
problem...
> 1) why does the current PowerMac version covers only inb() and not outb() ?
> I had to add outb() exception table entries for 8xx.
Not sure, maybe historical loss ? :) You should CC paulus
> 2) Is the same wanted for other embedded PPC's?
It's up to you. It slows down those IOs, but on the other hand, inX/outX
aren't supposed to be very common anymore, at least not with "fast"
devices, and the IO itself is usually an order of magnitude slower than
doing those syncs...
> 3) How to make the misc.S exception entries and additional instructions
> selectable only on the platform who need it? #ifdef does not sound
> a good idea.
>
> Nevermind the "#ifdef CONFIG_ALL_PPC" crap - that needs to be done
> properly.
>
>
> Index: arch/ppc/kernel/misc.S
> ===================================================================
> RCS file: /mnt/test1/tslinux_mv21/linux-216/arch/ppc/kernel/misc.S,v
> retrieving revision 1.2
> diff -u -r1.2 misc.S
> --- arch/ppc/kernel/misc.S 22 Oct 2003 19:34:30 -0000 1.2
> +++ arch/ppc/kernel/misc.S 1 Jun 2005 17:59:30 -0000
> @@ -736,8 +736,23 @@
> subi r4,r4,1
> blelr-
> 00: lbz r5,0(r3)
> - eieio
> - stbu r5,1(r4)
> +01: eieio
> +02: stbu r5,1(r4)
> +03: twi 0, r5, 0
> +04: isync
> +05: nop
Hrm... the "twi/isync" stuff is not valid for a store. The reason for
doing twi here is to trigger a data dependency on the result of the load
(to make sure the load actually happens) and the isync to make sure that
twi has actually completed. For stores, you are stuffed... either your
HW don't do machine checks on stores, or you put a sync here and "hope"
you don't have write posting along the IO chain that would cause your
machine check to arrive too late...
Ben.
^ permalink raw reply
* Re: [PATCH][1/3] RapidIO support: core
From: Greg KH @ 2005-06-02 0:02 UTC (permalink / raw)
To: Matt Porter; +Cc: akpm, torvalds, linux-kernel, linuxppc-embedded
In-Reply-To: <20050601110836.A16559@cox.net>
On Wed, Jun 01, 2005 at 11:08:36AM -0700, Matt Porter wrote:
> Patch is 108KB and can be found here:
> ftp://source.mvista.com/pub/rio/l26_rio_core.patch
register_driver() does not return the number of devices bound to the
driver. So your comment in rio_register_driver() is incorrect. Just
return count.
Hm, if the patch was inline it would be easier to comment on stuff like
this, I'll wait till then for the rest :)
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH][1/3] RapidIO support: core
From: Greg KH @ 2005-06-02 0:00 UTC (permalink / raw)
To: Matt Porter; +Cc: akpm, torvalds, linux-kernel, linuxppc-embedded
In-Reply-To: <20050601110836.A16559@cox.net>
On Wed, Jun 01, 2005 at 11:08:36AM -0700, Matt Porter wrote:
> Adds a RapidIO subsystem to the kernel. RIO is a switched
> fabric interconnect used in higher-end embedded applications.
> The curious can look at the specs over at http://www.rapidio.org
>
> The core code implements enumeration/discovery, management of
> devices/resources, and interfaces for RIO drivers.
>
> There's a lot more to do to take advantages of all the hardware
> features. However, this should provide a good base for folks
> with RIO hardware to start contributing.
>
> Signed-off-by: Matt Porter <mporter@kernel.crashing.org>
>
> Patch is 108KB and can be found here:
> ftp://source.mvista.com/pub/rio/l26_rio_core.patch
Care to split it up into logical sections and post it? It should be
small enough to do so that way.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH][1/3] RapidIO support: core
From: Matt Porter @ 2005-06-01 22:58 UTC (permalink / raw)
To: linux-kernel, linuxppc-embedded
In-Reply-To: <20050601110836.A16559@cox.net>
On Wed, Jun 01, 2005 at 11:08:36AM -0700, Matt Porter wrote:
> Adds a RapidIO subsystem to the kernel. RIO is a switched
> fabric interconnect used in higher-end embedded applications.
> The curious can look at the specs over at http://www.rapidio.org
>
> The core code implements enumeration/discovery, management of
> devices/resources, and interfaces for RIO drivers.
I'm also hacking on a rioutils package (derived from pciutils)
that has a lsrio that works pretty much like the familiar
lspci tool. The initial release can be grabbed from:
ftp://source.mvista.com/pub/rio/rioutils-0.10.tar.bz2
-Matt
^ permalink raw reply
* Re: RFC: PHY Abstraction Layer II
From: Andy Fleming @ 2005-06-01 22:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Netdev, Embedded PPC Linux list
In-Reply-To: <429E2653.6010101@osdl.org>
On Jun 1, 2005, at 16:19, Stephen Hemminger wrote:
> Andy Fleming wrote:
>>
>> But not this one. The phy_read and phy_write functions are
>> reading from and writing to a bus. It is a reasonable
>> implementation to have the operation block in the bus driver, and
>> be awoken when an interrupt signals the operation is done. All
>> of the phydev spinlocks have been arranged so as to prevent the
>> lock being taken during interrupt time.
>>
>> Unless I've misunderstood spinlocks (it wouldn't be the first
>> time), as long as the lock is never taken in interrupt time, it
>> should be ok to hold the lock, and wait for an interrupt before
>> clearing the lock.
>>
>
>
> The problem is that sleeping is defined in the linux kernel as
> meaning waiting on a mutual exclusion
> primitive (like semaphore) that puts the current thread to sleep.
> It is not legal to sleep with a spinlock held.
> In the phy_read code you do:
> spin_lock_bh(&bus->mdio_lock);
> retval = bus->read(bus, phydev->addr, regnum);
> spin_unlock_bh(&bus->mdio_lock);
>
> If the bus->read function were to do something like start a request
> and wait on a semaphore, then
> you would be sleeping with a spin lock held. So bus->read can not
> sleep! (as sleep is defined in the
> linux kernel).
Hmm... I understand this reasoning, but I still need a way for a bus
read to wait for an interrupt before returning. I suppose I can just
have the code spin while it waits, but that seems wrong, somehow.
I'm open to any suggestions.
^ permalink raw reply
* Re: RFC: PHY Abstraction Layer II
From: Andy Fleming @ 2005-06-01 22:36 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Netdev, Embedded PPC Linux list
In-Reply-To: <20050601144123.2bc11c06@dxpl.pdx.osdl.net>
On Jun 1, 2005, at 16:41, Stephen Hemminger wrote:
> On Wed, 1 Jun 2005 15:45:26 -0500
> Andy Fleming <afleming@freescale.com> wrote:
>>
>>> * get rid of bus read may sleep implication in comment.
>>> since you are holding phy spin lock it better not!!
>>>
>>
>>
>
> On a different note, I am not sure that using sysfs/kobject bus object
> is the right thing for this object. Isn't the phy instance really
> just
> an kobject whose parent is the network device? I can't see a 1 to N
> relationship between phy bus and phy objects existing.
Well, the MII Management bus is, in fact, a bus. When a network
driver wants to modify a PHY, it must access that bus. Many ethernet
controllers have a 1 to 1 relationship, since a typical NIC is a PCI
card with 1 ethernet port (meaning one controller, and one PHY).
However, many systems have multiple ethernet controllers attached to
one bus, which configures multiple PHYs. Currently, these systems
have been relying on luck to prevent multiple accesses to the same bus.
This tends to work because all of the PHY support is contained within
the ethernet driver, so it is easy for such drivers to ensure that
only one PHY transaction is done at a time. This system begins to
fall apart, though, when the PHY drivers start operating more
independently to react to changing PHY state. It really begins to
fall apart if you have multiple drivers trying to access a shared
bus. For instance, the 8560 ADS board has 2 gigabit ethernet ports
controlled by the gianfar driver, and 2 10/100 ports in the CPM
subsystem, controlled by the fcc_enet driver.
These two drivers each have an access point for the bus, which use
different mechanisms (one is a bit bang interface, and one is
register based). Using the new abstraction, it is possible for the
FCC driver to use the gianfar driver's bus, thus saving code, and
reducing complexity.
>
> The main use I can see for being a driver object is to catch
> suspend/resume,
> and wouldn't you want that to be tied to the network device.
It would be quite easy for the network driver to suspend or resume
the PHY and bus objects under the new abstraction. However, if eth0
is suspended, should it suspend the whole bus, and all the PHYs on
it? By making the MII bus an independent entity, eth0 can be
suspended, and it can choose to suspend its PHY, but eth1 can
continue to access its PHY over the bus, since those aren't suspended.
^ permalink raw reply
* Re: Tiny patch for arch/ppc/kernel/cputable.c to properly support the IBM PowerPC 750CXe rev 3.1
From: Benjamin Herrenschmidt @ 2005-06-01 22:26 UTC (permalink / raw)
To: Nicolas DET; +Cc: linuxppc-dev
In-Reply-To: <20050601171555.9E86B1C00209@mwinf0808.wanadoo.fr>
On Wed, 2005-06-01 at 19:14 +0100, Nicolas DET wrote:
> Hello,
>
> You can find enclosed a small patch to properly support the 750 CXe rev
> 3.1. Indeed, the current kernel (2.6.11.11) only supports rev 2.1 and
> ignores 3.1
>
> It's a tiny patch: it only add an entry in the table with the correct PVR
> and name. Others values has been copied from 750CXe rev 2.1.
>
> I succesfully patched & compiled a vanila 2.6.11.11 from kernel.org.
Is it needed ? I have it in my local tree and never actuall remembered
to actually send it :) In general, that kind of entries are really only
needed when there is a feature change...
Ben.
^ permalink raw reply
* [RFC] handle access to non-present IO ports on 8xx
From: Marcelo Tosatti @ 2005-06-01 16:50 UTC (permalink / raw)
To: linux-ppc-embedded, Pantelis Antoniou, Dan Malek
Hi,
Accessing non present "IO ports" on 8xx generates MCE's. The exception is easily
triggered during insertion/removal/suspension of PCMCIA cards.
The following (against ancient v2.4) adds exception table entries for I/O
instructions on 8xx (copied from the original Paul's PowerMac code), and
changes MachineCheckException() slightly to cover 8xx specific's (on 8xx
the MCE can be generated while executing the IO access instruction itself,
which is not the case on PowerMac's, as the comment on traps.c details).
A few things I'm wondering:
1) why does the current PowerMac version covers only inb() and not outb() ?
I had to add outb() exception table entries for 8xx.
2) Is the same wanted for other embedded PPC's?
3) How to make the misc.S exception entries and additional instructions
selectable only on the platform who need it? #ifdef does not sound
a good idea.
Nevermind the "#ifdef CONFIG_ALL_PPC" crap - that needs to be done
properly.
Index: arch/ppc/kernel/misc.S
===================================================================
RCS file: /mnt/test1/tslinux_mv21/linux-216/arch/ppc/kernel/misc.S,v
retrieving revision 1.2
diff -u -r1.2 misc.S
--- arch/ppc/kernel/misc.S 22 Oct 2003 19:34:30 -0000 1.2
+++ arch/ppc/kernel/misc.S 1 Jun 2005 17:59:30 -0000
@@ -736,8 +736,23 @@
subi r4,r4,1
blelr-
00: lbz r5,0(r3)
- eieio
- stbu r5,1(r4)
+01: eieio
+02: stbu r5,1(r4)
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
blr
@@ -747,10 +762,27 @@
subi r4,r4,1
blelr-
00: lbzu r5,1(r4)
- stb r5,0(r3)
- eieio
+01: stb r5,0(r3)
+02: eieio
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
+
bdnz 00b
- blr
+9: blr
+
_GLOBAL(_insw)
cmpwi 0,r5,0
@@ -758,10 +790,25 @@
subi r4,r4,2
blelr-
00: lhbrx r5,0,r3
- eieio
- sthu r5,2(r4)
+01: eieio
+02: sthu r5,2(r4)
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
- blr
+9: blr
_GLOBAL(_outsw)
cmpwi 0,r5,0
@@ -769,10 +816,25 @@
subi r4,r4,2
blelr-
00: lhzu r5,2(r4)
- eieio
- sthbrx r5,0,r3
+01: eieio
+02: sthbrx r5,0,r3
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
- blr
+9: blr
_GLOBAL(_insl)
cmpwi 0,r5,0
@@ -780,10 +842,25 @@
subi r4,r4,4
blelr-
00: lwbrx r5,0,r3
- eieio
- stwu r5,4(r4)
+01: eieio
+02: stwu r5,4(r4)
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
- blr
+9: blr
_GLOBAL(_outsl)
cmpwi 0,r5,0
@@ -791,10 +868,26 @@
subi r4,r4,4
blelr-
00: lwzu r5,4(r4)
- stwbrx r5,0,r3
- eieio
+01: stwbrx r5,0,r3
+02: eieio
+02: stwu r5,4(r4)
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
- blr
+9: blr
_GLOBAL(ide_insw)
_GLOBAL(_insw_ns)
@@ -803,10 +896,25 @@
subi r4,r4,2
blelr-
00: lhz r5,0(r3)
- eieio
- sthu r5,2(r4)
+01: eieio
+02: sthu r5,2(r4)
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: blr
+ .previous
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .previous
bdnz 00b
- blr
+9: blr
_GLOBAL(ide_outsw)
_GLOBAL(_outsw_ns)
@@ -815,10 +923,25 @@
subi r4,r4,2
blelr-
00: lhzu r5,2(r4)
- sth r5,0(r3)
- eieio
+01: sth r5,0(r3)
+02: eieio
+03: twi 0, r5, 0
+04: isync
+05: nop
+06: .section .fixup,"ax"
+07: b 9f
+ .text
+08: .section __ex_table, "a"
+ .align 2
+ .long 00b, 07b
+ .long 01b, 07b
+ .long 02b, 07b
+ .long 03b, 07b
+ .long 04b, 07b
+ .long 05b, 07b
+ .text
bdnz 00b
- blr
+9: blr
_GLOBAL(_insl_ns)
cmpwi 0,r5,0
@@ -826,10 +949,10 @@
subi r4,r4,4
blelr-
00: lwz r5,0(r3)
- eieio
- stwu r5,4(r4)
+01: eieio
+02: stwu r5,4(r4)
bdnz 00b
- blr
+9: blr
_GLOBAL(_outsl_ns)
cmpwi 0,r5,0
@@ -837,10 +960,10 @@
subi r4,r4,4
blelr-
00: lwzu r5,4(r4)
- stw r5,0(r3)
- eieio
+01: stw r5,0(r3)
+02: eieio
bdnz 00b
- blr
+9: blr
/*
* Extended precision shifts.
Index: arch/ppc/kernel/traps.c
===================================================================
RCS file: /mnt/test1/tslinux_mv21/linux-216/arch/ppc/kernel/traps.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 traps.c
--- arch/ppc/kernel/traps.c 19 Jun 2002 18:15:32 -0000 1.1.1.1
+++ arch/ppc/kernel/traps.c 1 Jun 2005 19:09:15 -0000
@@ -130,9 +130,7 @@
void
MachineCheckException(struct pt_regs *regs)
{
-#ifdef CONFIG_ALL_PPC
unsigned long fixup;
-#endif /* CONFIG_ALL_PPC */
unsigned long msr = regs->msr;
if (user_mode(regs)) {
@@ -150,7 +148,7 @@
return;
}
-#ifdef CONFIG_ALL_PPC
+//#ifdef CONFIG_ALL_PPC
/*
* I/O accesses can cause machine checks on powermacs.
* Check if the NIP corresponds to the address of a sync
@@ -176,20 +174,25 @@
nip -= 2;
else if (*nip == 0x4c00012c) /* isync */
--nip;
- if (*nip == 0x7c0004ac || (*nip >> 26) == 3) {
+ /* eieio from I/O string functions */
+ else if ((*nip) == 0x7c0006ac || *(nip+1) == 0x7c0006ac)
+ nip += 2;
+
+ if (*nip == 0x7c0004ac || (*(nip+1) >> 26) == 3 ||
+ (*nip >> 26) == 3) {
/* sync or twi */
unsigned int rb;
--nip;
rb = (*nip >> 11) & 0x1f;
- printk(KERN_DEBUG "%s bad port %lx at %p\n",
+ printk(KERN_ERR "%s bad port %lx at %p\n",
(*nip & 0x100)? "OUT to": "IN from",
regs->gpr[rb] - _IO_BASE, nip);
regs->nip = fixup;
return;
}
}
-#endif /* CONFIG_ALL_PPC */
+//#endif /* CONFIG_ALL_PPC */
printk("Machine check in kernel mode.\n");
printk("Caused by (from SRR1=%lx): ", msr);
switch (msr & 0x601F0000) {
Index: include/asm-ppc/io.h
===================================================================
RCS file: /mnt/test1/tslinux_mv21/linux-216/include/asm-ppc/io.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 io.h
--- include/asm-ppc/io.h 19 Jun 2002 18:16:26 -0000 1.1.1.1
+++ include/asm-ppc/io.h 30 May 2005 21:12:38 -0000
@@ -82,7 +82,7 @@
#define insl(port, buf, nl) _insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
#define outsl(port, buf, nl) _outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
-#ifdef CONFIG_ALL_PPC
+#ifdef CONFIG_8xx
/*
* On powermacs, we will get a machine check exception if we
* try to read data from a non-existent I/O port. Because the
@@ -105,7 +105,7 @@
{ \
unsigned int x; \
__asm__ __volatile__( \
- op " %0,0,%1\n" \
+ "0:" op " %0,0,%1\n" \
"1: twi 0,%0,0\n" \
"2: isync\n" \
"3: nop\n" \
@@ -116,6 +116,7 @@
".previous\n" \
".section __ex_table,\"a\"\n" \
" .align 2\n" \
+ " .long 0b,5b\n" \
" .long 1b,5b\n" \
" .long 2b,5b\n" \
" .long 3b,5b\n" \
@@ -129,12 +130,20 @@
extern __inline__ void name(unsigned int val, unsigned int port) \
{ \
__asm__ __volatile__( \
- op " %0,0,%1\n" \
- "1: sync\n" \
- "2:\n" \
+ "0:" op " %0,0,%1\n" \
+ "1: twi 0, %0, 0\n" \
+ "2: isync\n" \
+ "3: nop\n" \
+ "4:\n" \
+ ".section .fixup,\"ax\"\n" \
+ "5: b 4b\n" \
+ ".previous\n" \
".section __ex_table,\"a\"\n" \
" .align 2\n" \
- " .long 1b,2b\n" \
+ " .long 0b,5b\n" \
+ " .long 1b,5b\n" \
+ " .long 2b,5b\n" \
+ " .long 3b,5b\n" \
".previous" \
: : "r" (val), "r" (port + _IO_BASE)); \
}
^ permalink raw reply
* Re: Booting the linux-ppc64 kernel & flattened device tree v0.4
From: Benjamin Herrenschmidt @ 2005-06-01 21:58 UTC (permalink / raw)
To: Jon Loeliger; +Cc: linuxppc-embedded@ozlabs.org
In-Reply-To: <1117655671.6517.99.camel@cashmere.sps.mot.com>
On Wed, 2005-06-01 at 14:54 -0500, Jon Loeliger wrote:
> On Wed, 2005-06-01 at 03:26, Benjamin Herrenschmidt wrote:
> > DO NOT REPLY TO ALL LISTS PLEASE ! (and CC me on replies).
> >
> > Here's the fourth version of my document along with new kernel patches
> > for the new improved flattened format, and the first release of the
> > device-tree "compiler" tool. The patches will be posted as a reply to
> > this email. The compiler, dtc, can be downloaded, the URL is in the
> > document.
> >
> > ---
>
> >
> > dtc source code can be found at <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
>
> Ben,
>
> Here are diffs to:
>
> - Fix multi-line C-style comments.
>
> - Adjust the output of write_tree_source() such that it
> separates properties and nodes a bit better.
Excellent, thanks. Please CC david next time.
Ben.
^ permalink raw reply
* Re: Booting the linux-ppc64 kernel & flattened device tree v0.4
From: Benjamin Herrenschmidt @ 2005-06-01 21:56 UTC (permalink / raw)
To: Jon Loeliger; +Cc: linuxppc-embedded@ozlabs.org, David Gibson
In-Reply-To: <1117645131.6517.31.camel@cashmere.sps.mot.com>
On Wed, 2005-06-01 at 11:58 -0500, Jon Loeliger wrote:
> On Wed, 2005-06-01 at 03:26, Benjamin Herrenschmidt wrote:
> > Here's the fourth version of my document along with new kernel patches
> > for the new improved flattened format, and the first release of the
> > device-tree "compiler" tool. The patches will be posted as a reply to
> > this email. The compiler, dtc, can be downloaded, the URL is in the
> > document.
>
> Ben,
>
> Does it make sense to do this as well?
You mean include lsprop ? Well, I have another version of lsprop hacked
here that can generate a "source", but dtc can do it too now ... I think
we may just make dtc able to output in "lsprop" format too :) But I'll
talk to david (CC'd, he's the author of dtc).
Ben.
^ permalink raw reply
* [PATCH] [RFC] ppc32 (linux-2.6.11.4): remove the limitation of 2MB consistent DMA memory on ppc440
From: Shawn Jin @ 2005-06-01 21:55 UTC (permalink / raw)
To: ppcembed, Ahamed K, Rafiq (HP)
In-Reply-To: <1B5A11557D6A86458B1AD15DBBDB6CE2066D8CF4@tayexc13.americas.cpqcorp.net>
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
Hi,
This patch removes the limitation of 2MB consistent DMA memory on
ppc440. Originally consistent_pte was allocated only one page no
matter what value of CONFIG_CONSISTENT_SIZE is set. By default
CONFIG_CONSISTENT_SIZE is 0x200000. This causes some troubles on high
performance I/O applications which may require more than 2MB
consistent DMA memory.
The modifications allocate multiple pages for consistent pte table
according to CONFIG_CONSISTENT_SIZE. For example if
CONFIG_CONSISTENT_SIZE is set to 4MB, 2 pages are allocated for
consistent pte table. Please note that CONFIG_CONSISTENT_SIZE cannot
be any value. You have to find a free continuous memory space on your
system memory mapping.
The patch was tested successfully on Ocotea board. But I'm not sure if
it works on other systems. Use it at your own risk. However feedback
is more than welcome. :)
Regards,
-Shawn.
[-- Attachment #2: dma-mapping.patch --]
[-- Type: application/octet-stream, Size: 4203 bytes --]
--- orig/linux-2.6.11.4/arch/ppc/kernel/dma-mapping.c 2005-03-15 16:08:58.000000000 -0800
+++ linux-2.6.11.4/arch/ppc/kernel/dma-mapping.c 2005-05-27 19:06:27.956937000 -0700
@@ -17,6 +17,11 @@
* implementation. This is pulled straight from ARM and barely
* modified. -Matt
*
+ * Changed consistent_pte to consistent_ptes, in order to remove the
+ * limitation of 2MB consistent DMA memory. Now the size is confined by
+ * CONFIG_CONSISTENT_SIZE. And there are multiple pages containing PTE.
+ * - Xiaogeng (Shawn) Jin (Agilent Technologies), 2005
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
@@ -66,11 +71,14 @@
#define CONSISTENT_BASE (CONFIG_CONSISTENT_START)
#define CONSISTENT_END (CONFIG_CONSISTENT_START + CONFIG_CONSISTENT_SIZE)
#define CONSISTENT_OFFSET(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT)
+#define CONSISTENT_PTE_PAGENR ((CONFIG_CONSISTENT_SIZE >> PAGE_SHIFT) >> PTE_SHIFT)
+#define CONSISTENT_SIZE_PER_PTEPAGE (1UL << (PAGE_SHIFT + PTE_SHIFT))
/*
- * This is the page table (2MB) covering uncached, DMA consistent allocations
+ * This is page tables covering uncached, DMA consistent allocations,
+ * with the size of CONFIG_CONSISTENT_SIZE
*/
-static pte_t *consistent_pte;
+pte_t **consistent_ptes = NULL;
static DEFINE_SPINLOCK(consistent_lock);
/*
@@ -180,7 +188,7 @@
unsigned long order;
u64 mask = 0x00ffffff, limit; /* ISA default */
- if (!consistent_pte) {
+ if (!consistent_ptes) {
printk(KERN_ERR "%s: not initialised\n", __func__);
dump_stack();
return NULL;
@@ -219,9 +227,14 @@
c = vm_region_alloc(&consistent_head, size,
gfp & ~(__GFP_DMA | __GFP_HIGHMEM));
if (c) {
- pte_t *pte = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
+ pte_t *pte;
+ int offset = CONSISTENT_OFFSET(c->vm_start);
+ int idx = offset >> PTE_SHIFT;
struct page *end = page + (1 << order);
+ offset &= (1 << PTE_SHIFT) - 1;
+ pte = consistent_ptes[idx] + offset;
+
/*
* Set the "dma handle"
*/
@@ -235,6 +248,11 @@
set_pte(pte, mk_pte(page, pgprot_noncached(PAGE_KERNEL)));
page++;
pte++;
+ offset++;
+ if (offset > ((1 << PTE_SHIFT) - 1)) {
+ pte = consistent_ptes[++idx];
+ offset = 0;
+ }
} while (size -= PAGE_SIZE);
/*
@@ -264,6 +282,7 @@
struct vm_region *c;
unsigned long flags;
pte_t *ptep;
+ int offset, idx;
size = PAGE_ALIGN(size);
@@ -280,12 +299,21 @@
size = c->vm_end - c->vm_start;
}
- ptep = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
+ offset = CONSISTENT_OFFSET(c->vm_start);
+ idx = offset >> PTE_SHIFT;
+ offset &= (1 << PTE_SHIFT) - 1;
+ ptep = consistent_ptes[idx] + offset;
+
do {
pte_t pte = ptep_get_and_clear(ptep);
unsigned long pfn;
ptep++;
+ offset++;
+ if (offset > ((1 << PTE_SHIFT) - 1)) {
+ ptep = consistent_ptes[++idx];
+ offset = 0;
+ }
if (!pte_none(pte) && pte_present(pte)) {
pfn = pte_pfn(pte);
@@ -328,13 +356,22 @@
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
- int ret = 0;
+ int ret = 0, i;
+ unsigned long address;
spin_lock(&init_mm.page_table_lock);
- do {
- pgd = pgd_offset(&init_mm, CONSISTENT_BASE);
- pmd = pmd_alloc(&init_mm, pgd, CONSISTENT_BASE);
+ consistent_ptes = (pte_t **)kmalloc(sizeof(pte_t **) *
+ CONSISTENT_PTE_PAGENR, GFP_KERNEL);
+ if (!consistent_ptes) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+
+ for (i = 0, address = CONSISTENT_BASE; i < CONSISTENT_PTE_PAGENR; i++) {
+ pgd = pgd_offset(&init_mm, address);
+ pmd = pmd_alloc(&init_mm, pgd, address);
if (!pmd) {
printk(KERN_ERR "%s: no pmd tables\n", __func__);
ret = -ENOMEM;
@@ -342,16 +379,19 @@
}
WARN_ON(!pmd_none(*pmd));
- pte = pte_alloc_kernel(&init_mm, pmd, CONSISTENT_BASE);
+ pte = pte_alloc_kernel(&init_mm, pmd, address);
if (!pte) {
printk(KERN_ERR "%s: no pte tables\n", __func__);
ret = -ENOMEM;
break;
}
- consistent_pte = pte;
- } while (0);
+ consistent_ptes[i] = pte;
+
+ address += CONSISTENT_SIZE_PER_PTEPAGE;
+ }
+out:
spin_unlock(&init_mm.page_table_lock);
return ret;
^ permalink raw reply
* Re: RFC: PHY Abstraction Layer II
From: Stephen Hemminger @ 2005-06-01 21:41 UTC (permalink / raw)
To: Andy Fleming; +Cc: Netdev, Embedded PPC Linux list
In-Reply-To: <92F1428A-0B26-428B-8C06-35C7E5B9EEE3@freescale.com>
On Wed, 1 Jun 2005 15:45:26 -0500
Andy Fleming <afleming@freescale.com> wrote:
>
> On May 31, 2005, at 12:59, Stephen Hemminger wrote:
>
> > Here are some patches:
> > * allow phy's to be modules
> > * use driver owner for ref count
> > * make local functions static where ever possible
>
> I agree with all these.
>
> > * get rid of bus read may sleep implication in comment.
> > since you are holding phy spin lock it better not!!
>
On a different note, I am not sure that using sysfs/kobject bus object
is the right thing for this object. Isn't the phy instance really just
an kobject whose parent is the network device? I can't see a 1 to N
relationship between phy bus and phy objects existing.
The main use I can see for being a driver object is to catch suspend/resume,
and wouldn't you want that to be tied to the network device.
^ permalink raw reply
* Does linuxppc_2_4_devel still accept patch?
From: ming lei @ 2005-06-01 21:32 UTC (permalink / raw)
To: linuxppc-embedded
In-Reply-To: <20050524133819.B23084@cox.net>
Hi,
I found there is a serious problem in head_440.S
regarding the handling of mmucr in DataTLBmiss and
InstructionTLBmiss exceptions in 2.4 linux ppc branch.
Where should I submit the changes?
Which branch right now is active for ppc44x
development? Have we moved to linux kernel 2.6
official development already?
Ming
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply
* Re: RFC: PHY Abstraction Layer II
From: Stephen Hemminger @ 2005-06-01 21:19 UTC (permalink / raw)
To: Andy Fleming; +Cc: Netdev, Embedded PPC Linux list
In-Reply-To: <92F1428A-0B26-428B-8C06-35C7E5B9EEE3@freescale.com>
Andy Fleming wrote:
>
> On May 31, 2005, at 12:59, Stephen Hemminger wrote:
>
>> Here are some patches:
>> * allow phy's to be modules
>> * use driver owner for ref count
>> * make local functions static where ever possible
>
>
> I agree with all these.
>
>> * get rid of bus read may sleep implication in comment.
>> since you are holding phy spin lock it better not!!
>
>
> But not this one. The phy_read and phy_write functions are reading
> from and writing to a bus. It is a reasonable implementation to have
> the operation block in the bus driver, and be awoken when an
> interrupt signals the operation is done. All of the phydev spinlocks
> have been arranged so as to prevent the lock being taken during
> interrupt time.
>
> Unless I've misunderstood spinlocks (it wouldn't be the first time),
> as long as the lock is never taken in interrupt time, it should be ok
> to hold the lock, and wait for an interrupt before clearing the lock.
The problem is that sleeping is defined in the linux kernel as meaning
waiting on a mutual exclusion
primitive (like semaphore) that puts the current thread to sleep. It is
not legal to sleep with a spinlock held.
In the phy_read code you do:
spin_lock_bh(&bus->mdio_lock);
retval = bus->read(bus, phydev->addr, regnum);
spin_unlock_bh(&bus->mdio_lock);
If the bus->read function were to do something like start a request and
wait on a semaphore, then
you would be sleeping with a spin lock held. So bus->read can not
sleep! (as sleep is defined in the
linux kernel).
^ permalink raw reply
* Re: RFC: PHY Abstraction Layer II
From: Andy Fleming @ 2005-06-01 20:45 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Netdev, Embedded PPC Linux list
In-Reply-To: <20050531105939.7486e071@dxpl.pdx.osdl.net>
On May 31, 2005, at 12:59, Stephen Hemminger wrote:
> Here are some patches:
> * allow phy's to be modules
> * use driver owner for ref count
> * make local functions static where ever possible
I agree with all these.
> * get rid of bus read may sleep implication in comment.
> since you are holding phy spin lock it better not!!
But not this one. The phy_read and phy_write functions are reading
from and writing to a bus. It is a reasonable implementation to have
the operation block in the bus driver, and be awoken when an
interrupt signals the operation is done. All of the phydev spinlocks
have been arranged so as to prevent the lock being taken during
interrupt time.
Unless I've misunderstood spinlocks (it wouldn't be the first time),
as long as the lock is never taken in interrupt time, it should be ok
to hold the lock, and wait for an interrupt before clearing the lock.
Andy Fleming
^ permalink raw reply
* Re: Booting the linux-ppc64 kernel & flattened device tree v0.4
From: Jon Loeliger @ 2005-06-01 19:54 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-embedded@ozlabs.org
In-Reply-To: <1117614390.19020.24.camel@gaston>
On Wed, 2005-06-01 at 03:26, Benjamin Herrenschmidt wrote:
> DO NOT REPLY TO ALL LISTS PLEASE ! (and CC me on replies).
>
> Here's the fourth version of my document along with new kernel patches
> for the new improved flattened format, and the first release of the
> device-tree "compiler" tool. The patches will be posted as a reply to
> this email. The compiler, dtc, can be downloaded, the URL is in the
> document.
>
> ---
>
> dtc source code can be found at <http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
Ben,
Here are diffs to:
- Fix multi-line C-style comments.
- Adjust the output of write_tree_source() such that it
separates properties and nodes a bit better.
Thanks,
jdl
diff -u dtc.orig/dtc-lexer.l dtc/dtc-lexer.l
--- dtc.orig/dtc-lexer.l 2005-06-01 11:44:29.000002000 -0500
+++ dtc/dtc-lexer.l 2005-06-01 13:39:56.000001000 -0500
@@ -34,8 +34,6 @@
#include "y.tab.h"
-#undef LEXDEBUG 1
-
%}
\"[^"]*\" {
@@ -102,7 +100,7 @@
<*>{WS}+ /* eat whitespace */
-<*>\/\*[^*]*(\*[^/][^*])*\*\/ /* eat comments */
+<*>\/\*([^*]|\**[^*/])*\*+\/ /* eat C comments */
<*>\/\/.*\n /* eat line comments */
diff -u dtc.orig/treesource.c dtc/treesource.c
--- dtc.orig/treesource.c 2005-06-01 11:44:29.000002000 -0500
+++ dtc/treesource.c 2005-06-01 13:58:33.000001000 -0500
@@ -131,10 +131,16 @@
break;
}
}
- fprintf(f, "\n");
+ if (tree->children) {
+ fprintf(f, "\n");
+ }
for_each_child(tree, child) {
write_tree_source(f, child, level+1);
}
write_prefix(f, level);
fprintf(f, "};\n");
+
+ if (tree->next_sibling) {
+ fprintf(f, "\n");
+ }
}
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox