drivers/media/pci/cobalt/cobalt-flash.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cobalt/cobalt-flash.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cobalt/cobalt-flash.c- Extension
.c- Size
- 2384 bytes
- Lines
- 117
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mtd/mtd.hlinux/mtd/map.hlinux/mtd/cfi.hlinux/time.hcobalt-flash.h
Detected Declarations
function flash_read16function flash_write16function flash_copy_fromfunction flash_copy_tofunction cobalt_flash_probefunction cobalt_flash_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Cobalt NOR flash functions
*
* Copyright 2012-2015 Cisco Systems, Inc. and/or its affiliates.
* All rights reserved.
*/
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi.h>
#include <linux/time.h>
#include "cobalt-flash.h"
#define ADRS(offset) (COBALT_BUS_FLASH_BASE + offset)
static struct map_info cobalt_flash_map = {
.name = "cobalt-flash",
.bankwidth = 2, /* 16 bits */
.size = 0x4000000, /* 64MB */
.phys = 0, /* offset */
};
static map_word flash_read16(struct map_info *map, unsigned long offset)
{
map_word r;
r.x[0] = cobalt_bus_read32(map->virt, ADRS(offset));
if (offset & 0x2)
r.x[0] >>= 16;
else
r.x[0] &= 0x0000ffff;
return r;
}
static void flash_write16(struct map_info *map, const map_word datum,
unsigned long offset)
{
u16 data = (u16)datum.x[0];
cobalt_bus_write16(map->virt, ADRS(offset), data);
}
static void flash_copy_from(struct map_info *map, void *to,
unsigned long from, ssize_t len)
{
u32 src = from;
u8 *dest = to;
u32 data;
while (len) {
data = cobalt_bus_read32(map->virt, ADRS(src));
do {
*dest = data >> (8 * (src & 3));
src++;
dest++;
len--;
} while (len && (src % 4));
}
}
static void flash_copy_to(struct map_info *map, unsigned long to,
const void *from, ssize_t len)
{
const u8 *src = from;
u32 dest = to;
pr_info("%s: offset 0x%x: length %zu\n", __func__, dest, len);
while (len) {
u16 data;
do {
data = *src << (8 * (dest & 1));
src++;
dest++;
len--;
} while (len && (dest % 2));
cobalt_bus_write16(map->virt, ADRS(dest - 2), data);
}
}
int cobalt_flash_probe(struct cobalt *cobalt)
{
struct map_info *map = &cobalt_flash_map;
struct mtd_info *mtd;
BUG_ON(!map_bankwidth_supported(map->bankwidth));
Annotation
- Immediate include surface: `linux/mtd/mtd.h`, `linux/mtd/map.h`, `linux/mtd/cfi.h`, `linux/time.h`, `cobalt-flash.h`.
- Detected declarations: `function flash_read16`, `function flash_write16`, `function flash_copy_from`, `function flash_copy_to`, `function cobalt_flash_probe`, `function cobalt_flash_remove`.
- Atlas domain: Driver Families / drivers/media.
- 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.