#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbookpro_machdep.c,v 1.4 2023/09/09 07:07:03 andvar Exp $");
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/mutex.h>
#include <sys/param.h>
#include <uvm/uvm.h>
#include <machine/bootconfig.h>
#include <machine/pmap.h>
#include <arm/xscale/pxa2x0_gpio.h>
#include <hpcarm/dev/nbppconvar.h>
#include <dev/cons.h>
#include <dev/i2c/i2cvar.h>
#include "nbppcon.h"
#include "biconsdev.h"
#if NBICONSDEV > 0
#include <dev/hpc/bicons.h>
cons_decl(bicons);
#endif
#include "wsdisplay.h"
#if NWSDISPLAY == 0
#include <dev/wscons/wskbdvar.h>
#endif
static void netbookpro_reset(void);
void pxa2x0_machdep_init(void);
static int __unused enable_console(void (*)(struct consdev *),
void (*)(struct consdev *));
static void disable_consoles(void);
static void cn_nonprobe(struct consdev *);
const struct pmap_devmap machdep_devmap[] = {
DEVMAP_ENTRY(
0x14000000,
0x14000000,
0x00400000
),
DEVMAP_ENTRY_END
};
static struct pxa2x0_gpioconf netbookpro_boarddep_gpioconf[] = {
{ 6, GPIO_CLR | GPIO_ALT_FN_1_OUT },
{ 8, GPIO_CLR | GPIO_ALT_FN_1_OUT },
{ 52, GPIO_CLR | GPIO_ALT_FN_2_OUT },
{ 53, GPIO_CLR | GPIO_ALT_FN_2_OUT },
{ -1 }
};
static struct pxa2x0_gpioconf *netbookpro_gpioconf[] = {
pxa25x_pcic_gpioconf,
netbookpro_boarddep_gpioconf,
NULL
};
static void
netbookpro_reset(void)
{
device_t pcon;
pcon = device_find_by_xname("nbppcon0");
#if NNBPPCON > 0
if (pcon != NULL)
nbppcon_pwr_hwreset(pcon);
#endif
while (1 );
}
void
pxa2x0_machdep_init(void)
{
extern void (*__cpu_reset)(void);
extern void (*__sleep_func)(void *);
extern BootConfig bootconfig;
__cpu_reset = netbookpro_reset;
__sleep_func = NULL;
bootconfig.dram[0].pages = 32768;
pxa2x0_gpio_config(netbookpro_gpioconf);
}
void
consinit(void)
{
static int consinit_called = 0;
if (consinit_called != 0)
return;
consinit_called = 1;
disable_consoles();
#if NBICONSDEV > 0
enable_console(biconscninit, biconscnprobe);
bicons_set_priority(CN_INTERNAL);
cninit();
#if NWSDISPLAY == 0
if (cn_tab != NULL) {
cn_tab->cn_getc = wskbd_cngetc;
cn_tab->cn_pollc = wskbd_cnpollc;
cn_tab->cn_bell = wskbd_cnbell;
}
#endif
#endif
}
static int __unused
enable_console(void (*init)(struct consdev *), void (*probe)(struct consdev *))
{
struct consdev *cp;
for (cp = constab; cp->cn_probe; cp++) {
if (cp->cn_init == init) {
cp->cn_probe = probe;
return 1;
}
}
return 0;
}
static void
disable_consoles(void)
{
struct consdev *cp;
for (cp = constab; cp->cn_probe; cp++)
cp->cn_probe = cn_nonprobe;
}
static void
cn_nonprobe(struct consdev *cp)
{
cp->cn_pri = CN_DEAD;
}