drivers/sh/maple/maple.c
Source file repositories/reference/linux-study-clean/drivers/sh/maple/maple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/sh/maple/maple.c- Extension
.c- Size
- 21794 bytes
- Lines
- 889
- Domain
- Driver Families
- Bucket
- drivers/sh
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/device.hlinux/interrupt.hlinux/list.hlinux/io.hlinux/slab.hlinux/maple.hlinux/dma-mapping.hlinux/delay.hlinux/module.hasm/cacheflush.hasm/dma.hasm/io.hmach/dma.hmach/sysasic.h
Detected Declarations
struct maple_device_specifyfunction maple_driver_registerfunction maple_driver_registerfunction maple_dma_resetfunction maple_getcond_callbackfunction maple_dma_donefunction maple_release_devicefunction maple_add_packetfunction maple_free_devfunction maple_build_blockfunction maple_sendfunction list_for_each_entry_safefunction maple_check_matching_driverfunction maple_detach_driverfunction maple_attach_driverfunction check_maple_devicefunction setup_maple_commandsfunction time_afterfunction maple_vblank_handlerfunction maple_map_subunitsfunction maple_clean_submapfunction maple_response_nonefunction maple_response_devinfofunction maple_response_fileerrfunction maple_port_rescanfunction maple_dma_handlerfunction list_for_each_entry_safefunction maple_dma_interruptfunction maple_vblank_interruptfunction maple_set_dma_interrupt_handlerfunction maple_set_vblank_interrupt_handlerfunction maple_get_dma_bufferfunction maple_match_bus_driverfunction maple_bus_releasefunction maple_bus_initmodule init maple_bus_initexport maple_driver_registerexport maple_driver_unregisterexport maple_getcond_callbackexport maple_add_packet
Annotated Snippet
static const struct bus_type maple_bus_type;
/**
* maple_driver_register - register a maple driver
* @drv: maple driver to be registered.
*
* Registers the passed in @drv, while updating the bus type.
* Devices with matching function IDs will be automatically probed.
*/
int maple_driver_register(struct maple_driver *drv)
{
if (!drv)
return -EINVAL;
drv->drv.bus = &maple_bus_type;
return driver_register(&drv->drv);
}
EXPORT_SYMBOL_GPL(maple_driver_register);
/**
* maple_driver_unregister - unregister a maple driver.
* @drv: maple driver to unregister.
*
* Cleans up after maple_driver_register(). To be invoked in the exit
* path of any module drivers.
*/
void maple_driver_unregister(struct maple_driver *drv)
{
driver_unregister(&drv->drv);
}
EXPORT_SYMBOL_GPL(maple_driver_unregister);
/* set hardware registers to enable next round of dma */
static void maple_dma_reset(void)
{
__raw_writel(MAPLE_MAGIC, MAPLE_RESET);
/* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
__raw_writel(1, MAPLE_TRIGTYPE);
/*
* Maple system register
* bits 31 - 16 timeout in units of 20nsec
* bit 12 hard trigger - set 0 to keep responding to VBLANK
* bits 9 - 8 set 00 for 2 Mbps, 01 for 1 Mbps
* bits 3 - 0 delay (in 1.3ms) between VBLANK and start of DMA
* max delay is 11
*/
__raw_writel(MAPLE_2MBPS | MAPLE_TIMEOUT(0xFFFF), MAPLE_SPEED);
__raw_writel(virt_to_phys(maple_sendbuf), MAPLE_DMAADDR);
__raw_writel(1, MAPLE_ENABLE);
}
/**
* maple_getcond_callback - setup handling MAPLE_COMMAND_GETCOND
* @dev: device responding
* @callback: handler callback
* @interval: interval in jiffies between callbacks
* @function: the function code for the device
*/
void maple_getcond_callback(struct maple_device *dev,
void (*callback) (struct mapleq *mq),
unsigned long interval, unsigned long function)
{
dev->callback = callback;
dev->interval = interval;
dev->function = cpu_to_be32(function);
dev->when = jiffies;
}
EXPORT_SYMBOL_GPL(maple_getcond_callback);
static int maple_dma_done(void)
{
return (__raw_readl(MAPLE_STATE) & 1) == 0;
}
static void maple_release_device(struct device *dev)
{
struct maple_device *mdev;
struct mapleq *mq;
mdev = to_maple_dev(dev);
mq = mdev->mq;
kmem_cache_free(maple_queue_cache, mq->recvbuf);
kfree(mq);
kfree(mdev);
}
/**
* maple_add_packet - add a single instruction to the maple bus queue
* @mdev: maple device
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/device.h`, `linux/interrupt.h`, `linux/list.h`, `linux/io.h`, `linux/slab.h`, `linux/maple.h`.
- Detected declarations: `struct maple_device_specify`, `function maple_driver_register`, `function maple_driver_register`, `function maple_dma_reset`, `function maple_getcond_callback`, `function maple_dma_done`, `function maple_release_device`, `function maple_add_packet`, `function maple_free_dev`, `function maple_build_block`.
- Atlas domain: Driver Families / drivers/sh.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.