- get rid of private bus space in ingenic_com.c
- move com to apbus - attach the other UARTs
This commit is contained in:
parent
1e82b93929
commit
ede3c3ba87
@ -1,4 +1,4 @@
|
||||
# $NetBSD: CI20,v 1.13 2015/04/06 14:12:28 martin Exp $
|
||||
# $NetBSD: CI20,v 1.14 2015/07/11 19:00:04 macallan Exp $
|
||||
#
|
||||
# MIPS Creator CI20
|
||||
#
|
||||
@ -7,7 +7,7 @@ include "arch/evbmips/conf/std.ingenic"
|
||||
|
||||
#options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "CI20-$Revision: 1.13 $"
|
||||
#ident "CI20-$Revision: 1.14 $"
|
||||
|
||||
maxusers 32
|
||||
|
||||
@ -43,7 +43,7 @@ options NTP # network time protocol
|
||||
|
||||
# Debugging options
|
||||
options DIAGNOSTIC # extra kernel sanity checking
|
||||
options DEBUG # extra kernel debugging support
|
||||
#options DEBUG # extra kernel debugging support
|
||||
#options KMEMSTATS # kernel memory statistics (vmstat -m)
|
||||
#options USERCONF # userconf(4) support
|
||||
#options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
|
||||
@ -134,15 +134,19 @@ options NFS_BOOT_DHCP
|
||||
|
||||
config netbsd root on sd0a type ffs
|
||||
#config netbsd root on axe0 type nfs
|
||||
#config netbsd root on dme0 type nfs
|
||||
|
||||
mainbus0 at root
|
||||
#options MULTIPROCESSOR
|
||||
|
||||
cpu0 at mainbus?
|
||||
#wdog0 at mainbus?
|
||||
com* at mainbus?
|
||||
apbus0 at mainbus?
|
||||
|
||||
# On-board USB
|
||||
# On-chip UARTs
|
||||
com* at apbus?
|
||||
|
||||
# On-chip USB
|
||||
dwctwo* at apbus?
|
||||
#options DWC2_DEBUG
|
||||
usb* at dwctwo?
|
||||
@ -150,17 +154,18 @@ usb* at dwctwo?
|
||||
ohci* at apbus?
|
||||
usb* at ohci?
|
||||
|
||||
# this one doesn't work yet
|
||||
# this one doesn't work right just yet
|
||||
#ehci* at apbus?
|
||||
#options INGENIC_EHCI_DEBUG
|
||||
#options EHCI_DEBUG
|
||||
#options USBVERBOSE
|
||||
#options USBHIST
|
||||
#usb* at ehci?
|
||||
|
||||
# onboard ethernet
|
||||
dme* at apbus?
|
||||
|
||||
# I2C/SMBus
|
||||
# Work in progress - can't do transfers over 15 bytes per direction,
|
||||
# no interrupts etc.
|
||||
# Good enough for talking to an RTC though, so it's enabled.
|
||||
jziic* at apbus?
|
||||
#options JZIIC_DEBUG # spammy
|
||||
iic* at jziic?
|
||||
@ -182,6 +187,12 @@ pcf8563rtc0 at iic4 addr 0x51
|
||||
#jzgpio* at apbus? addr ?
|
||||
#gpio* at jzgpio?
|
||||
|
||||
# MSC / SDMMC - unfinished
|
||||
#jzmmc* at apbus?
|
||||
#options JZMMC_DEBUG
|
||||
#sdmmc* at jzmmc?
|
||||
#ld* at sdmmc?
|
||||
|
||||
# USB stuff
|
||||
uhub* at usb?
|
||||
uhub* at uhub? port ?
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.8 2015/06/30 02:39:03 matt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.9 2015/07/11 19:00:04 macallan Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Michael Lorenz
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8 2015/06/30 02:39:03 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2015/07/11 19:00:04 macallan Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
@ -242,6 +242,7 @@ consinit(void)
|
||||
* Everything related to console initialization is done
|
||||
* in mach_init().
|
||||
*/
|
||||
apbus_init();
|
||||
ingenic_com_cnattach();
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,19 @@
|
||||
# $NetBSD: files.ingenic,v 1.5 2015/04/04 12:28:52 macallan Exp $
|
||||
# $NetBSD: files.ingenic,v 1.6 2015/07/11 19:00:04 macallan Exp $
|
||||
|
||||
include "dev/scsipi/files.scsipi" # SCSI devices
|
||||
include "dev/ata/files.ata" # ATA devices
|
||||
include "dev/usb/files.usb" # USB devices
|
||||
|
||||
# On-chip UART device
|
||||
attach com at mainbus with com_mainbus
|
||||
file arch/mips/ingenic/ingenic_com.c com_mainbus
|
||||
|
||||
# Ingenic system bus
|
||||
device apbus { [addr=-1] }
|
||||
attach apbus at mainbus
|
||||
file arch/mips/ingenic/apbus.c apbus
|
||||
|
||||
# On-chip UART device
|
||||
attach com at apbus with ingenic_com
|
||||
file arch/mips/ingenic/ingenic_com.c ingenic_com
|
||||
options COM_REGMAP
|
||||
|
||||
# USB
|
||||
attach dwctwo at apbus with ingenic_dwctwo
|
||||
file arch/mips/ingenic/ingenic_dwctwo.c ingenic_dwctwo needs-flag
|
||||
@ -22,6 +23,7 @@ file arch/mips/ingenic/ingenic_ohci.c ingenic_ohci needs-flag
|
||||
|
||||
attach ehci at apbus with ingenic_ehci
|
||||
file arch/mips/ingenic/ingenic_ehci.c ingenic_ehci needs-flag
|
||||
defflag opt_ingenic.h INGENIC_EHCI_DEBUG
|
||||
|
||||
# Ethernet
|
||||
attach dme at apbus with ingenic_dme
|
||||
@ -32,3 +34,9 @@ device jziic : i2cbus
|
||||
attach jziic at apbus
|
||||
file arch/mips/ingenic/jziic.c jziic
|
||||
defflag opt_ingenic.h JZIIC_DEBUG
|
||||
|
||||
# SDMMC
|
||||
device jzmmc : sdmmcbus
|
||||
attach jzmmc at apbus
|
||||
file arch/mips/ingenic/jzmmc.c jzmmc
|
||||
defflag opt_ingenic.h JZMMC_DEBUG
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: apbus.c,v 1.15 2015/05/18 15:07:52 macallan Exp $ */
|
||||
/* $NetBSD: apbus.c,v 1.16 2015/07/11 19:00:04 macallan Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Michael Lorenz
|
||||
@ -29,7 +29,7 @@
|
||||
/* catch-all for on-chip peripherals */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.15 2015/05/18 15:07:52 macallan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.16 2015/07/11 19:00:04 macallan Exp $");
|
||||
|
||||
#include "locators.h"
|
||||
#define _MIPS_BUS_DMA_PRIVATE
|
||||
@ -72,6 +72,11 @@ typedef struct apbus_dev {
|
||||
} apbus_dev_t;
|
||||
|
||||
static const apbus_dev_t apbus_devs[] = {
|
||||
{ "com", JZ_UART0, 51, CLK_UART0, 0, 0},
|
||||
{ "com", JZ_UART1, 50, CLK_UART1, 0, 0},
|
||||
{ "com", JZ_UART2, 49, CLK_UART2, 0, 0},
|
||||
{ "com", JZ_UART3, 48, CLK_UART3, 0, 0},
|
||||
{ "com", JZ_UART4, 34, 0, CLK_UART4, 0},
|
||||
{ "dwctwo", JZ_DWC2_BASE, 21, CLK_OTG0 | CLK_UHC, CLK_OTG1, 0},
|
||||
{ "ohci", JZ_OHCI_BASE, 5, CLK_UHC, 0, 0},
|
||||
{ "ehci", JZ_EHCI_BASE, 20, CLK_UHC, 0, 0},
|
||||
@ -181,7 +186,7 @@ apbus_attach(device_t parent, device_t self, void *aux)
|
||||
gpio_as_dev1(4, 12);
|
||||
gpio_as_dev1(4, 13);
|
||||
/* these can be DDC2 or SMB4 */
|
||||
#if 1
|
||||
#if 0
|
||||
/* DDC2 devices show up at SMB4 */
|
||||
gpio_as_dev1(5, 24);
|
||||
gpio_as_dev1(5, 25);
|
||||
@ -219,7 +224,7 @@ apbus_attach(device_t parent, device_t self, void *aux)
|
||||
gpio_as_dev0(1, 30);
|
||||
gpio_as_dev0(1, 31);
|
||||
|
||||
#ifdef INGENIC_DEBUG
|
||||
#ifndef INGENIC_DEBUG
|
||||
printf("JZ_CLKGR0 %08x\n", readreg(JZ_CLKGR0));
|
||||
printf("JZ_CLKGR1 %08x\n", readreg(JZ_CLKGR1));
|
||||
printf("JZ_SPCR0 %08x\n", readreg(JZ_SPCR0));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ingenic_com.c,v 1.4 2015/03/07 15:35:33 macallan Exp $ */
|
||||
/* $NetBSD: ingenic_com.c,v 1.5 2015/07/11 19:00:04 macallan Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Michael Lorenz
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.4 2015/03/07 15:35:33 macallan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.5 2015/07/11 19:00:04 macallan Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -45,10 +45,15 @@ __KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.4 2015/03/07 15:35:33 macallan Exp
|
||||
|
||||
#include <mips/cpuregs.h>
|
||||
|
||||
#include <mips/ingenic/ingenic_var.h>
|
||||
#include <mips/ingenic/ingenic_regs.h>
|
||||
|
||||
#include "opt_com.h"
|
||||
|
||||
#ifndef COM_REGMAP
|
||||
#error We need COM_REGMAP
|
||||
#endif
|
||||
|
||||
volatile int32_t *com0addr = (int32_t *)MIPS_PHYS_TO_KSEG1(JZ_UART0);
|
||||
|
||||
void ingenic_putchar_init(void);
|
||||
@ -60,9 +65,6 @@ void ingenic_putchar(char);
|
||||
#endif
|
||||
|
||||
|
||||
static struct mips_bus_space ingenic_com_mbst;
|
||||
static int mbst_valid = 0;
|
||||
static void ingenic_com_bus_mem_init(bus_space_tag_t, void *);
|
||||
void ingenic_com_cnattach(void);
|
||||
|
||||
static int ingenic_com_match(device_t, cfdata_t , void *);
|
||||
@ -70,12 +72,17 @@ static void ingenic_com_attach(device_t, device_t, void *);
|
||||
|
||||
struct ingenic_com_softc {
|
||||
struct com_softc sc_com;
|
||||
bus_space_tag_t sc_tag;
|
||||
bus_space_handle_t sc_regh;
|
||||
};
|
||||
|
||||
CFATTACH_DECL_NEW(com_mainbus, sizeof(struct ingenic_com_softc),
|
||||
CFATTACH_DECL_NEW(ingenic_com, sizeof(struct ingenic_com_softc),
|
||||
ingenic_com_match, ingenic_com_attach, NULL, NULL);
|
||||
|
||||
bus_space_handle_t regh = 0;
|
||||
static bus_space_handle_t regh = 0;
|
||||
static bus_addr_t cons_com = 0;
|
||||
static struct com_regs regs;
|
||||
extern bus_space_tag_t apbus_memt;
|
||||
|
||||
void
|
||||
ingenic_putchar_init(void)
|
||||
@ -138,31 +145,20 @@ ingenic_puts(const char *restrict s)
|
||||
ingenic_putchar(c);
|
||||
}
|
||||
|
||||
static void
|
||||
ingenic_com_bus_init(void)
|
||||
{
|
||||
if (mbst_valid) return;
|
||||
ingenic_com_bus_mem_init(&ingenic_com_mbst, NULL);
|
||||
mbst_valid = 1;
|
||||
}
|
||||
|
||||
void
|
||||
ingenic_com_cnattach(void)
|
||||
{
|
||||
struct com_regs regs;
|
||||
int i;
|
||||
|
||||
ingenic_com_bus_init();
|
||||
bus_space_map(&ingenic_com_mbst, 0, 0x1000, 0, ®h);
|
||||
|
||||
bus_space_map(apbus_memt, JZ_UART0, 0x100, 0, ®h);
|
||||
cons_com = JZ_UART0;
|
||||
memset(®s, 0, sizeof(regs));
|
||||
COM_INIT_REGS(regs, &ingenic_com_mbst, regh, 0);
|
||||
COM_INIT_REGS(regs, apbus_memt, regh, JZ_UART0);
|
||||
for (i = 0; i < 16; i++) {
|
||||
regs.cr_map[i] = regs.cr_map[i] << 2;
|
||||
}
|
||||
regs.cr_nports = 32;
|
||||
|
||||
/*
|
||||
* XXX
|
||||
* UART clock is either 6MHz or 12MHz, the manual is rather unclear
|
||||
* so we just leave alone whatever u-boot set up
|
||||
* my uplcom is too tolerant to show any difference
|
||||
*/
|
||||
comcnattach1(®s, 115200, 48000000, COM_TYPE_INGENIC, CONMODE);
|
||||
}
|
||||
|
||||
@ -182,24 +178,25 @@ ingenic_com_attach(device_t parent, device_t self, void *args)
|
||||
{
|
||||
struct ingenic_com_softc *isc = device_private(self);
|
||||
struct com_softc *sc = &isc->sc_com;
|
||||
struct apbus_attach_args *aa = args;
|
||||
int i;
|
||||
|
||||
sc->sc_dev = self;
|
||||
sc->sc_frequency = 48000000;
|
||||
sc->sc_type = COM_TYPE_INGENIC;
|
||||
isc->sc_tag = aa->aa_bst;
|
||||
|
||||
if (cons_com == aa->aa_addr) {
|
||||
isc->sc_regh = regh;
|
||||
} else {
|
||||
bus_space_map(apbus_memt, aa->aa_addr, 0x1000, 0, &isc->sc_regh);
|
||||
}
|
||||
memset(&sc->sc_regs, 0, sizeof(sc->sc_regs));
|
||||
COM_INIT_REGS(sc->sc_regs, &ingenic_com_mbst, regh, 0);
|
||||
COM_INIT_REGS(sc->sc_regs, aa->aa_bst, isc->sc_regh, aa->aa_addr);
|
||||
for (i = 0; i < 16; i++)
|
||||
sc->sc_regs.cr_map[i] = sc->sc_regs.cr_map[i] << 2;
|
||||
sc->sc_regs.cr_nports = 32;
|
||||
|
||||
com_attach_subr(sc);
|
||||
printf("\n");
|
||||
evbmips_intr_establish(51, comintr, sc);
|
||||
evbmips_intr_establish(aa->aa_irq, comintr, sc);
|
||||
}
|
||||
|
||||
#define CHIP ingenic_com
|
||||
#define CHIP_MEM /* defined */
|
||||
#define CHIP_W1_BUS_START(v) 0x00000000UL
|
||||
#define CHIP_W1_BUS_END(v) 0x00010000UL
|
||||
#define CHIP_W1_SYS_START(v) 0x10030000UL
|
||||
#define CHIP_W1_SYS_END(v) 0x10035000UL
|
||||
#define CHIP_ACCESS_SIZE 1
|
||||
#define CHIP_ALIGN_STRIDE 2
|
||||
|
||||
#include <mips/mips/bus_space_alignstride_chipdep.c>
|
||||
|
Loading…
Reference in New Issue
Block a user