Commit dbcb4a1a authored by Chris Metcalf's avatar Chris Metcalf

arch/tile: add hypervisor-based character driver for SPI flash ROM

The first version of this patch proposed an arch/tile/drivers/ directory,
but the consensus was that this was probably a poor choice for a place to
group Tilera-specific drivers, and that in any case grouping by platform
was discouraged, and grouping by function was preferred.

This version of the patch addresses various issues raised in the
community, primarily the absence of sysfs integration.  The sysfs
integration now handles passing information on sector size, page size,
and total partition size to userspace as well.  In addition, we now
use a single "struct cdev" to manage all the partition minor devices,
and dynamically discover the correct number of partitions from the
hypervisor rather than using a module_param with a default value.

This driver has no particular "peer" drivers it can be grouped with.
It is sort of like an MTD driver for SPI ROM, but it doesn't group well
with the other MTD devices since it relies on hypervisor virtualization
to handle many of the irritating aspects of flash ROM management: sector
awareness, background read for sub-sector writes, bit examination to
determine whether a sector erase needs to be issued, etc.  It is in fact
more like an EEPROM driver, but the hypervisor virtualization does require
a "flush" command if you wish to commit a sector write prior to writing
to a different sector, and this is sufficiently different from generic
I2C/SPI EEPROMs that as a result it doesn't group well with them either.

The simple character device is already in use by a range of Tilera
SPI ROM management tools, as well as by customers.  In addition, using
the simple character device actually simplifies the userspace tools,
since they don't need to manage sector erase, background read, etc.
This both simplifies the code (since we can uniformly manage plain files
and the SPI ROM) as well as makes the user code portable to non-Linux
platforms that don't offer the same MTD ioctls.
Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
parent ea41b1e5
/*
* Copyright 2011 Tilera Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for
* more details.
*/
/**
* @file drv_srom_intf.h
* Interface definitions for the SPI Flash ROM driver.
*/
#ifndef _SYS_HV_INCLUDE_DRV_SROM_INTF_H
#define _SYS_HV_INCLUDE_DRV_SROM_INTF_H
/** Read this offset to get the total device size. */
#define SROM_TOTAL_SIZE_OFF 0xF0000000
/** Read this offset to get the device sector size. */
#define SROM_SECTOR_SIZE_OFF 0xF0000004
/** Read this offset to get the device page size. */
#define SROM_PAGE_SIZE_OFF 0xF0000008
/** Write this offset to flush any pending writes. */
#define SROM_FLUSH_OFF 0xF1000000
/** Write this offset, plus the byte offset of the start of a sector, to
* erase a sector. Any write data is ignored, but there must be at least
* one byte of write data. Only applies when the driver is in MTD mode.
*/
#define SROM_ERASE_OFF 0xF2000000
#endif /* _SYS_HV_INCLUDE_DRV_SROM_INTF_H */
...@@ -616,5 +616,16 @@ config MSM_SMD_PKT ...@@ -616,5 +616,16 @@ config MSM_SMD_PKT
Enables userspace clients to read and write to some packet SMD Enables userspace clients to read and write to some packet SMD
ports via device interface for MSM chipset. ports via device interface for MSM chipset.
config TILE_SROM
bool "Character-device access via hypervisor to the Tilera SPI ROM"
depends on TILE
default y
---help---
This device provides character-level read-write access
to the SROM, typically via the "0", "1", and "2" devices
in /dev/srom/. The Tilera hypervisor makes the flash
device appear much like a simple EEPROM, and knows
how to partition a single ROM for multiple purposes.
endmenu endmenu
...@@ -63,3 +63,5 @@ obj-$(CONFIG_RAMOOPS) += ramoops.o ...@@ -63,3 +63,5 @@ obj-$(CONFIG_RAMOOPS) += ramoops.o
obj-$(CONFIG_JS_RTC) += js-rtc.o obj-$(CONFIG_JS_RTC) += js-rtc.o
js-rtc-y = rtc.o js-rtc-y = rtc.o
obj-$(CONFIG_TILE_SROM) += tile-srom.o
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment