HP300 core updates
Subsystems (2)
Geert Uytterhoeven
maintainerPATCH 1/1 HP300 core updates
Update of HP300 core support to use bootinfo etc. (from Kars de Jong)
Signed-off-by Kars de Jong <[email protected]>
Signed-off-by Geert Uytterhoeven <[email protected]>
arch/m68k/hp300/config.c +241 -25
@@ -7,56 +7,272 @@* called by setup.c. */ -#include <linux/config.h> -#include <linux/types.h> -#include <linux/mm.h> -#include <linux/kd.h> -#include <linux/tty.h> -#include <linux/console.h> -#include <linux/interrupt.h> +#include <linux/module.h> #include <linux/init.h> +#include <linux/string.h> +#include <linux/kernel.h> +#include <linux/console.h> + +#include <asm/bootinfo.h> #include <asm/machdep.h> #include <asm/blinken.h> -#include <asm/hwtest.h> /* hwreg_present() */ +#include <asm/io.h> /* readb() and writeb() */ +#include <asm/hp300hw.h> +#include <asm/rtc.h> #include "ints.h" #include "time.h" +unsigned long hp300_model; +unsigned long hp300_uart_scode =-1 ; +unsigned char ledstate; + +static char s_hp330[]__initdata ="330" ; +static char s_hp340[]__initdata ="340" ; +static char s_hp345[]__initdata ="345" ; +static char s_hp360[]__initdata ="360" ; +static char s_hp370[]__initdata ="370" ; +static char s_hp375[]__initdata ="375" ; +static char s_hp380[]__initdata ="380" ; +static char s_hp385[]__initdata ="385" ; +static char s_hp400[]__initdata ="400" ; +static char s_hp425t[]__initdata ="425t" ; +static char s_hp425s[]__initdata ="425s" ; +static char s_hp425e[]__initdata ="425e" ; +static char s_hp433t[]__initdata ="433t" ; +static char s_hp433s[]__initdata ="433s" ; +static char *hp300_models[]__initdata = { + [HP_320 ] =NULL , + [HP_330 ] = s_hp330, + [HP_340 ] = s_hp340, + [HP_345 ] = s_hp345, + [HP_350 ] =NULL , + [HP_360 ] = s_hp360, + [HP_370 ] = s_hp370, + [HP_375 ] = s_hp375, + [HP_380 ] = s_hp380, + [HP_385 ] = s_hp385, + [HP_400 ] = s_hp400, + [HP_425T ] = s_hp425t, + [HP_425S ] = s_hp425s, + [HP_425E ] = s_hp425e, + [HP_433T ] = s_hp433t, + [HP_433S ] = s_hp433s, +}; + +static char hp300_model_name[13 ] ="HP9000/" ; +extern void hp300_reset (void );extern irqreturn_t (*hp300_default_handler[])(int ,void *,struct pt_regs *);extern int show_hp300_interrupts (struct seq_file *,void *); +#ifdef CONFIG_SERIAL_8250_CONSOLE +extern int hp300_setup_serial_console (void )__init ; +#endif + +int __init hp300_parse_bootinfo (const struct bi_record *record) +{ +int unknown =0 ; +const unsigned long *data = record->data; + +switch (record->tag) { +case BI_HP300_MODEL : + hp300_model = *data; +break ; + +case BI_HP300_UART_SCODE : + hp300_uart_scode = *data; +break ; + +case BI_HP300_UART_ADDR : +/* serial port address: ignored here */ +break ; + +default : + unknown =1 ; + } + +return unknown; +}#ifdef CONFIG_HEARTBEAT static void hp300_pulse (int x) { -if (x) -blinken_leds (0xfe ); -else -blinken_leds (0xff ); +if (x) +blinken_leds (0x10 ,0 ); +else +blinken_leds (0 ,0x10 ); }#endif static void hp300_get_model (char *model) { -strcpy (model,"HP9000/300" ); +strcpy (model, hp300_model_name); +} + +#define RTCBASE 0xf0420000 +#define RTC_DATA 0x1 +#define RTC_CMD 0x3 + +#define RTC_BUSY 0x02 +#define RTC_DATA_RDY 0x01 + +#define rtc_busy () (in_8(RTCBASE + RTC_CMD) & RTC_BUSY) +#define rtc_data_available () (in_8(RTCBASE + RTC_CMD) & RTC_DATA_RDY) +#define rtc_status () (in_8(RTCBASE + RTC_CMD)) +#define rtc_command (x) out_8(RTCBASE + RTC_CMD, (x)) +#define rtc_read_data () (in_8(RTCBASE + RTC_DATA)) +#define rtc_write_data (x) out_8(RTCBASE + RTC_DATA, (x)) + +#define RTC_SETREG 0xe0 +#define RTC_WRITEREG 0xc2 +#define RTC_READREG 0xc3 + +#define RTC_REG_SEC2 0 +#define RTC_REG_SEC1 1 +#define RTC_REG_MIN2 2 +#define RTC_REG_MIN1 3 +#define RTC_REG_HOUR2 4 +#define RTC_REG_HOUR1 5 +#define RTC_REG_WDAY 6 +#define RTC_REG_DAY2 7 +#define RTC_REG_DAY1 8 +#define RTC_REG_MON2 9 +#define RTC_REG_MON1 10 +#define RTC_REG_YEAR2 11 +#define RTC_REG_YEAR1 12 + +#define RTC_HOUR1_24HMODE 0x8 + +#define RTC_STAT_MASK 0xf0 +#define RTC_STAT_RDY 0x40 + +static inline unsigned char hp300_rtc_read (unsigned char reg) +{ +unsigned char s, ret; +unsigned long flags; + +local_irq_save (flags); + +while (rtc_busy ()); +rtc_command (RTC_SETREG ); +while (rtc_busy ()); +rtc_write_data (reg); +while (rtc_busy ()); +rtc_command (RTC_READREG ); + +do { +while (!rtc_data_available ()); + s =rtc_status (); + ret =rtc_read_data (); + }while ((s &RTC_STAT_MASK ) !=RTC_STAT_RDY ); + +local_irq_restore (flags); + +return ret; +} + +static inline unsigned char hp300_rtc_write (unsigned char reg, +unsigned char val) +{ +unsigned char s, ret; +unsigned long flags; + +local_irq_save (flags); + +while (rtc_busy ()); +rtc_command (RTC_SETREG ); +while (rtc_busy ()); +rtc_write_data ((val <<4 ) | reg); +while (rtc_busy ()); +rtc_command (RTC_WRITEREG ); +while (rtc_busy ()); +rtc_command (RTC_READREG ); + +do { +while (!rtc_data_available ()); + s =rtc_status (); + ret =rtc_read_data (); + }while ((s &RTC_STAT_MASK ) !=RTC_STAT_RDY ); + +local_irq_restore (flags); + +return ret; +} + +static int hp300_hwclk (int op,struct rtc_time *t) +{ +if (!op) {/* read */ + t->tm_sec =hp300_rtc_read (RTC_REG_SEC1 ) *10 + +hp300_rtc_read (RTC_REG_SEC2 ); + t->tm_min =hp300_rtc_read (RTC_REG_MIN1 ) *10 + +hp300_rtc_read (RTC_REG_MIN2 ); + t->tm_hour = (hp300_rtc_read (RTC_REG_HOUR1 ) &3 ) *10 + +hp300_rtc_read (RTC_REG_HOUR2 ); + t->tm_wday =-1 ; + t->tm_mday =hp300_rtc_read (RTC_REG_DAY1 ) *10 + +hp300_rtc_read (RTC_REG_DAY2 ); + t->tm_mon =hp300_rtc_read (RTC_REG_MON1 ) *10 + +hp300_rtc_read (RTC_REG_MON2 ) -1 ; + t->tm_year =hp300_rtc_read (RTC_REG_YEAR1 ) *10 + +hp300_rtc_read (RTC_REG_YEAR2 ); +if (t->tm_year <=69 ) + t->tm_year +=100 ; + }else { +hp300_rtc_write (RTC_REG_SEC1 , t->tm_sec /10 ); +hp300_rtc_write (RTC_REG_SEC2 , t->tm_sec %10 ); +hp300_rtc_write (RTC_REG_MIN1 , t->tm_min /10 ); +hp300_rtc_write (RTC_REG_MIN2 , t->tm_min %10 ); +hp300_rtc_write (RTC_REG_HOUR1 , + ((t->tm_hour /10 ) &3 ) |RTC_HOUR1_24HMODE ); +hp300_rtc_write (RTC_REG_HOUR2 , t->tm_hour %10 ); +hp300_rtc_write (RTC_REG_DAY1 , t->tm_mday /10 ); +hp300_rtc_write (RTC_REG_DAY2 , t->tm_mday %10 ); +hp300_rtc_write (RTC_REG_MON1 , (t->tm_mon +1 ) /10 ); +hp300_rtc_write (RTC_REG_MON2 , (t->tm_mon +1 ) %10 ); +if (t->tm_year >=100 ) + t->tm_year -=100 ; +hp300_rtc_write (RTC_REG_YEAR1 , t->tm_year /10 ); +hp300_rtc_write (RTC_REG_YEAR2 , t->tm_year %10 ); + } + +return 0 ; +} + +static unsigned int hp300_get_ss (void ) +{ +return hp300_rtc_read (RTC_REG_SEC1 ) *10 + +hp300_rtc_read (RTC_REG_SEC2 ); }void __init config_hp300 (void ) { - mach_sched_init = hp300_sched_init; - mach_init_IRQ = hp300_init_IRQ; - mach_request_irq = hp300_request_irq; - mach_free_irq = hp300_free_irq; - mach_get_model = hp300_get_model; - mach_get_irq_list = show_hp300_interrupts; - mach_gettimeoffset = hp300_gettimeoffset; - mach_default_handler = &hp300_default_handler; - mach_reset = hp300_reset; + mach_sched_init = hp300_sched_init; + mach_init_IRQ = hp300_init_IRQ; + mach_request_irq = hp300_request_irq; + mach_free_irq = hp300_free_irq; + mach_get_model = hp300_get_model; + mach_get_irq_list = show_hp300_interrupts; + mach_gettimeoffset = hp300_gettimeoffset; + mach_default_handler = &hp300_default_handler; + mach_hwclk = hp300_hwclk; + mach_get_ss = hp300_get_ss; + mach_reset = hp300_reset;#ifdef CONFIG_HEARTBEAT - mach_heartbeat = hp300_pulse; + mach_heartbeat = hp300_pulse;#endif #ifdef CONFIG_DUMMY_CONSOLE - conswitchp = &dummy_con; + conswitchp = &dummy_con; +#endif + mach_max_dma_address =0xffffffff ; + +if (hp300_model >=HP_330 && hp300_model <=HP_433S && hp300_model !=HP_350 ) { +printk (KERN_INFO "Detected HP9000 model %s\n" , hp300_models[hp300_model-HP_320 ]); +strcat (hp300_model_name, hp300_models[hp300_model-HP_320 ]); + } +else { +panic ("Unknown HP9000 Model" ); + } +#ifdef CONFIG_SERIAL_8250_CONSOLE +hp300_setup_serial_console ();#endif - mach_max_dma_address =0xffffffff ; }
arch/m68k/hp300/ints.c +8 -1
@@ -57,14 +57,21 @@return IRQ_HANDLED ; } +static irqreturn_t hp300_badint (int irq,void *dev_id,struct pt_regs *fp) +{ + num_spurious +=1 ; +return IRQ_NONE ; +} +irqreturn_t (*hp300_default_handler[SYS_IRQS ])(int ,void *,struct pt_regs *) = { - [0 ] = hp300_int_handler, + [0 ] = hp300_badint, [1 ] = hp300_int_handler, [2 ] = hp300_int_handler, [3 ] = hp300_int_handler, [4 ] = hp300_int_handler, [5 ] = hp300_int_handler, [6 ] = hp300_int_handler, + [7 ] = hp300_int_handler };/* dev_id had better be unique to each handler because it's the only way we have
arch/m68k/hp300/reboot.S +1 -20
@@ -13,23 +13,4 @@ .globl hp300_reset hp300_reset: - .chip 68030 - oriw #0x0700,%sr /* cli() */ - movel hp300_phys_ram_base, %d1 - movel #0, %d0 - movec %d0, %vbr /* reset vector table */ - lea zero, %a0 - lea 1f, %a1 - add %d1, %a0 - add %d1, %a1 - pmove %tc, %a0@ - bclr #7, %a0@ - pmove %a0@, %tc /* goodbye MMU */ - jmp %a1@ -1: movel #0x808, %d0 - movec %d0, %cacr /* cache off */ - moveb #0, 0x1ffff - movel #0x1a4, %a0 - jmp %a0@ - -zero: .quad 0 + jmp hp300_reset
arch/m68k/hp300/time.c +8 -5
@@ -17,6 +17,7 @@#include <asm/io.h> #include <asm/system.h> #include <asm/traps.h> +#include <asm/blinken.h> #include "ints.h" /* Clock hardware definitions */
@@ -38,11 +39,13 @@static irqreturn_t hp300_tick (int irq,void *dev_id,struct pt_regs *regs) { -unsigned long tmp; -irqreturn_t (*vector)(int ,void *,struct pt_regs *) = dev_id; -in_8 (CLOCKBASE +CLKSR ); - asmvolatile ("movpw %1@(5),%0" :"=d" (tmp) :"a" (CLOCKBASE )); -return vector (irq,NULL , regs); +unsigned long tmp; +irqreturn_t (*vector)(int ,void *,struct pt_regs *) = dev_id; +in_8 (CLOCKBASE +CLKSR ); + asmvolatile ("movpw %1@(5),%0" :"=d" (tmp) :"a" (CLOCKBASE )); +/* Turn off the network and SCSI leds */ +blinken_leds (0 ,0xe0 ); +return vector (irq,NULL , regs); }unsigned long hp300_gettimeoffset (void )
arch/m68k/kernel/head.S +94 -100
316 lines not on this page · raw message
arch/m68k/kernel/setup.c +5 -14
@@ -110,6 +110,7 @@extern int bvme6000_parse_bootinfo (const struct bi_record *);extern int mvme16x_parse_bootinfo (const struct bi_record *);extern int mvme147_parse_bootinfo (const struct bi_record *); +extern int hp300_parse_bootinfo (const struct bi_record *);extern void config_amiga (void );extern void config_atari (void );
@@ -176,6 +177,8 @@ unknown =mvme16x_parse_bootinfo (record); else if (MACH_IS_MVME147) unknown =mvme147_parse_bootinfo (record); + else if (MACH_IS_HP300) + unknown =hp300_parse_bootinfo (record); else unknown =1 ; }
@@ -205,20 +208,8 @@int i;char *p, *q; -if (!MACH_IS_HP300 ) { -/* The bootinfo is located right after the kernel bss */ -m68k_parse_bootinfo ((const struct bi_record *)&_end); - }else { -/* FIXME HP300 doesn't use bootinfo yet */ -extern unsigned long hp300_phys_ram_base; -unsigned long hp300_mem_size =0xffffffff -hp300_phys_ram_base; - m68k_cputype =CPU_68030 ; - m68k_fputype =FPU_68882 ; - m68k_memory[0 ].addr = hp300_phys_ram_base; -/* 0.5M fudge factor */ - m68k_memory[0 ].size = hp300_mem_size-512 *1024 ; - m68k_num_memory++; - } +/* The bootinfo is located right after the kernel bss */ +m68k_parse_bootinfo ((const struct bi_record *)&_end);if (CPU_IS_040 ) m68k_is040or060 =4 ;
include/asm-m68k/blinken.h +10 -5
@@ -13,15 +13,20 @@#define _M68K_BLINKEN_H#include <asm/setup.h> +#include <asm/io.h> #define HP300_LEDS 0xf001ffff -static __inline__void blinken_leds (int x) +extern unsigned char ledstate; + +static __inline__void blinken_leds (int on,int off) { -if (MACH_IS_HP300 ) - { - *((volatile unsigned char *)HP300_LEDS ) = (x); - } +if (MACH_IS_HP300 ) + { + ledstate |= on; + ledstate &= ~off; +out_8 (HP300_LEDS , ~ledstate); + } }#endif
include/asm-m68k/bootinfo.h +7 -0
@@ -213,7 +213,13 @@#define BI_APOLLO_MODEL 0x8000/* model (u_long) */ +/* +* HP300-specific tags +*/ +#define BI_HP300_MODEL 0x8000/* model (u_long) */ +#define BI_HP300_UART_SCODE 0x8001/* UART select code (u_long) */ +#define BI_HP300_UART_ADDR 0x8002/* phys. addr of UART (u_long) */ /* * Stuff for bootinfo interface versioning
@@ -255,6 +261,7 @@#define MVME16x_BOOTI_VERSION MK_BI_VERSION( 2, 0 )#define BVME6000_BOOTI_VERSION MK_BI_VERSION( 2, 0 )#define Q40_BOOTI_VERSION MK_BI_VERSION( 2, 0 ) +#define HP300_BOOTI_VERSION MK_BI_VERSION( 2, 0 )#ifdef BOOTINFO_COMPAT_1_0
include/asm-m68k/hp300hw.h +25 -0
@@ -0,0 +1,25 @@ +#ifndef _M68K_HP300HW_H +#define _M68K_HP300HW_H + +extern unsigned long hp300_model; + +/* This information was taken from NetBSD */ +#define HP_320 (0)/* 16MHz 68020+HP MMU+16K external cache */ +#define HP_330 (1)/* 16MHz 68020+68851 MMU */ +#define HP_340 (2)/* 16MHz 68030 */ +#define HP_345 (3)/* 50MHz 68030+32K external cache */ +#define HP_350 (4)/* 25MHz 68020+HP MMU+32K external cache */ +#define HP_360 (5)/* 25MHz 68030 */ +#define HP_370 (6)/* 33MHz 68030+64K external cache */ +#define HP_375 (7)/* 50MHz 68030+32K external cache */ +#define HP_380 (8)/* 25MHz 68040 */ +#define HP_385 (9)/* 33MHz 68040 */ + +#define HP_400 (10)/* 50MHz 68030+32K external cache */ +#define HP_425T (11)/* 25MHz 68040 - model 425t */ +#define HP_425S (12)/* 25MHz 68040 - model 425s */ +#define HP_425E (13)/* 25MHz 68040 - model 425e */ +#define HP_433T (14)/* 33MHz 68040 - model 433t */ +#define HP_433S (15)/* 33MHz 68040 - model 433s */ + +#endif /* _M68K_HP300HW_H */
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds