mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 01:34:12 +00:00
iodev: usb: replace secondary usb iodevs with single vuart iodev
Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
parent
3a2446c53b
commit
2724d69f4c
7 changed files with 31 additions and 33 deletions
|
@ -1068,7 +1068,7 @@ class HV(Reloadable):
|
|||
|
||||
zone = irange(base, 0x4000)
|
||||
irq = node.interrupts[0]
|
||||
self.p.hv_map_vuart(base, irq, getattr(IODEV, self.iodev.name + "_SEC"))
|
||||
self.p.hv_map_vuart(base, irq, self.iodev)
|
||||
self.add_tracer(zone, "VUART", TraceMode.RESERVED)
|
||||
|
||||
def map_essential(self):
|
||||
|
|
|
@ -423,10 +423,9 @@ class AlignmentError(Exception):
|
|||
class IODEV(IntEnum):
|
||||
UART = 0
|
||||
FB = 1
|
||||
USB0 = 2
|
||||
USB1 = 3
|
||||
USB0_SEC = 4
|
||||
USB1_SEC = 5
|
||||
USB_VUART = 2
|
||||
USB0 = 3
|
||||
USB1 = 4
|
||||
|
||||
class USAGE(IntFlag):
|
||||
CONSOLE = (1 << 0)
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
#include "hv.h"
|
||||
#include "aic.h"
|
||||
#include "iodev.h"
|
||||
#include "uart.h"
|
||||
#include "uart_regs.h"
|
||||
|
||||
static iodev_id_t vuart_iodev;
|
||||
#include "usb.h"
|
||||
|
||||
bool active = false;
|
||||
|
||||
|
@ -19,13 +19,13 @@ static void update_irq(void)
|
|||
{
|
||||
ssize_t rx_queued;
|
||||
|
||||
iodev_handle_events(vuart_iodev);
|
||||
iodev_handle_events(IODEV_USB_VUART);
|
||||
|
||||
utrstat |= UTRSTAT_TXBE | UTRSTAT_TXE;
|
||||
utrstat &= ~UTRSTAT_RXD;
|
||||
|
||||
ufstat = 0;
|
||||
if ((rx_queued = iodev_can_read(vuart_iodev))) {
|
||||
if ((rx_queued = iodev_can_read(IODEV_USB_VUART))) {
|
||||
utrstat |= UTRSTAT_RXD;
|
||||
if (rx_queued > 15)
|
||||
ufstat = FIELD_PREP(UFSTAT_RXCNT, 15) | UFSTAT_RXFULL;
|
||||
|
@ -70,8 +70,8 @@ static bool handle_vuart(struct exc_info *ctx, u64 addr, u64 *val, bool write, i
|
|||
break;
|
||||
case UTXH: {
|
||||
uint8_t b = *val;
|
||||
if (iodev_can_write(vuart_iodev))
|
||||
iodev_write(vuart_iodev, &b, 1);
|
||||
if (iodev_can_write(IODEV_USB_VUART))
|
||||
iodev_write(IODEV_USB_VUART, &b, 1);
|
||||
break;
|
||||
}
|
||||
case UTRSTAT:
|
||||
|
@ -84,9 +84,9 @@ static bool handle_vuart(struct exc_info *ctx, u64 addr, u64 *val, bool write, i
|
|||
*val = ucon;
|
||||
break;
|
||||
case URXH:
|
||||
if (iodev_can_read(vuart_iodev)) {
|
||||
if (iodev_can_read(IODEV_USB_VUART)) {
|
||||
uint8_t c;
|
||||
iodev_read(vuart_iodev, &c, 1);
|
||||
iodev_read(IODEV_USB_VUART, &c, 1);
|
||||
*val = c;
|
||||
} else {
|
||||
*val = 0;
|
||||
|
@ -119,7 +119,7 @@ void hv_vuart_poll(void)
|
|||
void hv_map_vuart(u64 base, int irq, iodev_id_t iodev)
|
||||
{
|
||||
hv_map_hook(base, handle_vuart, 0x1000);
|
||||
vuart_iodev = iodev;
|
||||
usb_iodev_vuart_setup(iodev);
|
||||
vuart_irq = irq;
|
||||
active = true;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
extern struct iodev iodev_uart;
|
||||
extern struct iodev iodev_fb;
|
||||
extern struct iodev iodev_usb[];
|
||||
extern struct iodev iodev_usb_sec[];
|
||||
extern struct iodev iodev_usb_vuart;
|
||||
|
||||
struct iodev *iodevs[IODEV_MAX] = {
|
||||
[IODEV_UART] = &iodev_uart, [IODEV_FB] = &iodev_fb,
|
||||
[IODEV_USB0] = &iodev_usb[0], [IODEV_USB1] = &iodev_usb[1],
|
||||
[IODEV_USB0_SEC] = &iodev_usb_sec[0], [IODEV_USB1_SEC] = &iodev_usb_sec[1],
|
||||
[IODEV_USB_VUART] = &iodev_usb_vuart, [IODEV_USB0] = &iodev_usb[0],
|
||||
[IODEV_USB1] = &iodev_usb[1],
|
||||
};
|
||||
|
||||
char con_buf[CONSOLE_BUFFER_SIZE];
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
typedef enum _iodev_id_t {
|
||||
IODEV_UART,
|
||||
IODEV_FB,
|
||||
IODEV_USB_VUART,
|
||||
IODEV_USB0,
|
||||
IODEV_USB1,
|
||||
IODEV_USB0_SEC,
|
||||
IODEV_USB1_SEC,
|
||||
IODEV_MAX,
|
||||
} iodev_id_t;
|
||||
|
||||
|
|
26
src/usb.c
26
src/usb.c
|
@ -218,17 +218,10 @@ struct iodev iodev_usb[USB_INSTANCES] = {
|
|||
},
|
||||
};
|
||||
|
||||
struct iodev iodev_usb_sec[USB_INSTANCES] = {
|
||||
{
|
||||
.ops = &iodev_usb_sec_ops,
|
||||
.usage = 0,
|
||||
.lock = SPINLOCK_INIT,
|
||||
},
|
||||
{
|
||||
.ops = &iodev_usb_sec_ops,
|
||||
.usage = 0,
|
||||
.lock = SPINLOCK_INIT,
|
||||
},
|
||||
struct iodev iodev_usb_vuart = {
|
||||
.ops = &iodev_usb_sec_ops,
|
||||
.usage = 0,
|
||||
.lock = SPINLOCK_INIT,
|
||||
};
|
||||
|
||||
static tps6598x_dev_t *hpm_init(i2c_dev_t *i2c, int idx)
|
||||
|
@ -338,8 +331,6 @@ void usb_iodev_init(void)
|
|||
if (!iodev_usb[i].opaque)
|
||||
continue;
|
||||
|
||||
iodev_usb_sec[i].opaque = iodev_usb[i].opaque;
|
||||
|
||||
printf("USB%d: initialized at %p\n", i, iodev_usb[i].opaque);
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +345,6 @@ void usb_iodev_shutdown(void)
|
|||
usb_dwc3_shutdown(iodev_usb[i].opaque);
|
||||
|
||||
iodev_usb[i].opaque = NULL;
|
||||
iodev_usb_sec[i].opaque = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,3 +359,11 @@ int usb_idx_from_address(u64 drd_base)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void usb_iodev_vuart_setup(iodev_id_t iodev)
|
||||
{
|
||||
if (iodev < IODEV_USB0 || iodev >= IODEV_USB0 + USB_INSTANCES)
|
||||
return;
|
||||
|
||||
iodev_usb_vuart.opaque = iodev_usb[iodev - IODEV_USB0].opaque;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#ifndef USB_H
|
||||
#define USB_H
|
||||
|
||||
#include "iodev.h"
|
||||
#include "types.h"
|
||||
#include "usb_dwc3.h"
|
||||
|
||||
|
@ -13,5 +14,6 @@ void usb_hpm_restore_irqs(bool force);
|
|||
void usb_iodev_init(void);
|
||||
void usb_iodev_shutdown(void);
|
||||
int usb_idx_from_address(u64 drd_base);
|
||||
void usb_iodev_vuart_setup(iodev_id_t iodev);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue