arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c- Extension
.c- Size
- 6240 bytes
- Lines
- 307
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/of_address.hmm/mmu_decl.hasm/io.hasm/udbg.hasm/fixmap.husbgecko_udbg.h
Detected Declarations
function ug_io_transactionfunction ug_is_adapter_presentfunction ug_is_txfifo_readyfunction ug_raw_putcfunction ug_putcfunction ug_is_rxfifo_readyfunction ug_raw_getcfunction ug_getcfunction ug_udbg_putcfunction ug_udbg_getcfunction ug_udbg_getc_pollfunction ug_udbg_probefunction ug_udbg_initfunction ug_early_grab_io_addrfunction udbg_init_usbgecko
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
*
* udbg serial input/output routines for the USB Gecko adapter.
* Copyright (C) 2008-2009 The GameCube Linux Team
* Copyright (C) 2008,2009 Albert Herranz
*/
#include <linux/of_address.h>
#include <mm/mmu_decl.h>
#include <asm/io.h>
#include <asm/udbg.h>
#include <asm/fixmap.h>
#include "usbgecko_udbg.h"
#define EXI_CLK_32MHZ 5
#define EXI_CSR 0x00
#define EXI_CSR_CLKMASK (0x7<<4)
#define EXI_CSR_CLK_32MHZ (EXI_CLK_32MHZ<<4)
#define EXI_CSR_CSMASK (0x7<<7)
#define EXI_CSR_CS_0 (0x1<<7) /* Chip Select 001 */
#define EXI_CR 0x0c
#define EXI_CR_TSTART (1<<0)
#define EXI_CR_WRITE (1<<2)
#define EXI_CR_READ_WRITE (2<<2)
#define EXI_CR_TLEN(len) (((len)-1)<<4)
#define EXI_DATA 0x10
#define UG_READ_ATTEMPTS 100
#define UG_WRITE_ATTEMPTS 100
static void __iomem *ug_io_base;
/*
* Performs one input/output transaction between the exi host and the usbgecko.
*/
static u32 ug_io_transaction(u32 in)
{
u32 __iomem *csr_reg = ug_io_base + EXI_CSR;
u32 __iomem *data_reg = ug_io_base + EXI_DATA;
u32 __iomem *cr_reg = ug_io_base + EXI_CR;
u32 csr, data, cr;
/* select */
csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
out_be32(csr_reg, csr);
/* read/write */
data = in;
out_be32(data_reg, data);
cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
out_be32(cr_reg, cr);
while (in_be32(cr_reg) & EXI_CR_TSTART)
barrier();
/* deselect */
out_be32(csr_reg, 0);
/* result */
data = in_be32(data_reg);
return data;
}
/*
* Returns true if an usbgecko adapter is found.
*/
static int ug_is_adapter_present(void)
{
if (!ug_io_base)
return 0;
return ug_io_transaction(0x90000000) == 0x04700000;
}
/*
* Returns true if the TX fifo is ready for transmission.
*/
static int ug_is_txfifo_ready(void)
{
Annotation
- Immediate include surface: `linux/of_address.h`, `mm/mmu_decl.h`, `asm/io.h`, `asm/udbg.h`, `asm/fixmap.h`, `usbgecko_udbg.h`.
- Detected declarations: `function ug_io_transaction`, `function ug_is_adapter_present`, `function ug_is_txfifo_ready`, `function ug_raw_putc`, `function ug_putc`, `function ug_is_rxfifo_ready`, `function ug_raw_getc`, `function ug_getc`, `function ug_udbg_putc`, `function ug_udbg_getc`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.