Release 4.7 drivers/macintosh/mediabay.c
/*
* Driver for the media bay on the PowerBook 3400 and 2400.
*
* Copyright (C) 1998 Paul Mackerras.
*
* Various evolutions by Benjamin Herrenschmidt & Henry Worth
*
* 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; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/stddef.h>
#include <linux/init.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
#include <asm/prom.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#include <asm/mediabay.h>
#include <asm/sections.h>
#include <asm/ohare.h>
#include <asm/heathrow.h>
#include <asm/keylargo.h>
#include <linux/adb.h>
#include <linux/pmu.h>
#define MB_FCR32(bay, r) ((bay)->base + ((r) >> 2))
#define MB_FCR8(bay, r) (((volatile u8 __iomem *)((bay)->base)) + (r))
#define MB_IN32(bay,r) (in_le32(MB_FCR32(bay,r)))
#define MB_OUT32(bay,r,v) (out_le32(MB_FCR32(bay,r), (v)))
#define MB_BIS(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) | (v)))
#define MB_BIC(bay,r,v) (MB_OUT32((bay), (r), MB_IN32((bay), r) & ~(v)))
#define MB_IN8(bay,r) (in_8(MB_FCR8(bay,r)))
#define MB_OUT8(bay,r,v) (out_8(MB_FCR8(bay,r), (v)))
struct media_bay_info;
struct mb_ops {
char* name;
void (*init)(struct media_bay_info *bay);
u8 (*content)(struct media_bay_info *bay);
void (*power)(struct media_bay_info *bay, int on_off);
int (*setup_bus)(struct media_bay_info *bay, u8 device_id);
void (*un_reset)(struct media_bay_info *bay);
void (*un_reset_ide)(struct media_bay_info *bay);
};
struct media_bay_info {
u32 __iomem *base;
int content_id;
int state;
int last_value;
int value_count;
int timer;
struct macio_dev *mdev;
const struct mb_ops* ops;
int index;
int cached_gpio;
int sleeping;
int user_lock;
struct mutex lock;
};
#define MAX_BAYS 2
static struct media_bay_info media_bays[MAX_BAYS];
static int media_bay_count = 0;
/*
* Wait that number of ms between each step in normal polling mode
*/
#define MB_POLL_DELAY 25
/*
* Consider the media-bay ID value stable if it is the same for
* this number of milliseconds
*/
#define MB_STABLE_DELAY 100
/* Wait after powering up the media bay this delay in ms
* timeout bumped for some powerbooks
*/
#define MB_POWER_DELAY 200
/*
* Hold the media-bay reset signal true for this many ticks
* after a device is inserted before releasing it.
*/
#define MB_RESET_DELAY 50
/*
* Wait this long after the reset signal is released and before doing
* further operations. After this delay, the IDE reset signal is released
* too for an IDE device
*/
#define MB_SETUP_DELAY 100
/*
* Wait this many ticks after an IDE device (e.g. CD-ROM) is inserted
* (or until the device is ready) before calling into the driver
*/
#define MB_IDE_WAIT 1000
/*
* States of a media bay
*/
enum {
mb_empty = 0, /* Idle */
mb_powering_up, /* power bit set, waiting MB_POWER_DELAY */
mb_enabling_bay, /* enable bits set, waiting MB_RESET_DELAY */
mb_resetting, /* reset bit unset, waiting MB_SETUP_DELAY */
mb_ide_resetting, /* IDE reset bit unser, waiting MB_IDE_WAIT */
mb_up, /* Media bay full */
mb_powering_down /* Powering down (avoid too fast down/up) */
};
#define MB_POWER_SOUND 0x08
#define MB_POWER_FLOPPY 0x04
#define MB_POWER_ATA 0x02
#define MB_POWER_PCI 0x01
#define MB_POWER_OFF 0x00
/*
* Functions for polling content of media bay
*/
static u8
ohare_mb_content(struct media_bay_info *bay)
{
return (MB_IN32(bay, OHARE_MBCR) >> 12) & 7;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 21 | 84.00% | 1 | 33.33% |
pre-git | pre-git | 4 | 16.00% | 2 | 66.67% |
| Total | 25 | 100.00% | 3 | 100.00% |
static u8
heathrow_mb_content(struct media_bay_info *bay)
{
return (MB_IN32(bay, HEATHROW_MBCR) >> 12) & 7;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 20 | 80.00% | 1 | 50.00% |
pre-git | pre-git | 5 | 20.00% | 1 | 50.00% |
| Total | 25 | 100.00% | 2 | 100.00% |
static u8
keylargo_mb_content(struct media_bay_info *bay)
{
int new_gpio;
new_gpio = MB_IN8(bay, KL_GPIO_MEDIABAY_IRQ) & KEYLARGO_GPIO_INPUT_DATA;
if (new_gpio) {
bay->cached_gpio = new_gpio;
return MB_NO;
} else if (bay->cached_gpio != new_gpio) {
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
(void)MB_IN32(bay, KEYLARGO_MBCR);
udelay(5);
MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
(void)MB_IN32(bay, KEYLARGO_MBCR);
udelay(5);
bay->cached_gpio = new_gpio;
}
return (MB_IN32(bay, KEYLARGO_MBCR) >> 4) & 7;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 80 | 67.23% | 1 | 25.00% |
pre-git | pre-git | 39 | 32.77% | 3 | 75.00% |
| Total | 119 | 100.00% | 4 | 100.00% |
/*
* Functions for powering up/down the bay, puts the bay device
* into reset state as well
*/
static void
ohare_mb_power(struct media_bay_info* bay, int on_off)
{
if (on_off) {
/* Power up device, assert it's reset line */
MB_BIC(bay, OHARE_FCR, OH_BAY_RESET_N);
MB_BIC(bay, OHARE_FCR, OH_BAY_POWER_N);
} else {
/* Disable all devices */
MB_BIC(bay, OHARE_FCR, OH_BAY_DEV_MASK);
MB_BIC(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
/* Cut power from bay, release reset line */
MB_BIS(bay, OHARE_FCR, OH_BAY_POWER_N);
MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
}
MB_BIC(bay, OHARE_MBCR, 0x00000F00);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 70 | 71.43% | 1 | 33.33% |
pre-git | pre-git | 28 | 28.57% | 2 | 66.67% |
| Total | 98 | 100.00% | 3 | 100.00% |
static void
heathrow_mb_power(struct media_bay_info* bay, int on_off)
{
if (on_off) {
/* Power up device, assert it's reset line */
MB_BIC(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
MB_BIC(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
} else {
/* Disable all devices */
MB_BIC(bay, HEATHROW_FCR, HRW_BAY_DEV_MASK);
MB_BIC(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
/* Cut power from bay, release reset line */
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_POWER_N);
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
}
MB_BIC(bay, HEATHROW_MBCR, 0x00000F00);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 66 | 67.35% | 1 | 20.00% |
pre-git | pre-git | 32 | 32.65% | 4 | 80.00% |
| Total | 98 | 100.00% | 5 | 100.00% |
static void
keylargo_mb_power(struct media_bay_info* bay, int on_off)
{
if (on_off) {
/* Power up device, assert it's reset line */
MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
} else {
/* Disable all devices */
MB_BIC(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
/* Cut power from bay, release reset line */
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_POWER);
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
}
MB_BIC(bay, KEYLARGO_MBCR, 0x0000000F);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 50 | 51.02% | 3 | 75.00% |
paul mackerras | paul mackerras | 48 | 48.98% | 1 | 25.00% |
| Total | 98 | 100.00% | 4 | 100.00% |
/*
* Functions for configuring the media bay for a given type of device,
* enable the related busses
*/
static int
ohare_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
{
switch(device_id) {
case MB_FD:
case MB_FD1:
MB_BIS(bay, OHARE_FCR, OH_BAY_FLOPPY_ENABLE);
MB_BIS(bay, OHARE_FCR, OH_FLOPPY_ENABLE);
return 0;
case MB_CD:
MB_BIC(bay, OHARE_FCR, OH_IDE1_RESET_N);
MB_BIS(bay, OHARE_FCR, OH_BAY_IDE_ENABLE);
return 0;
case MB_PCI:
MB_BIS(bay, OHARE_FCR, OH_BAY_PCI_ENABLE);
return 0;
}
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 56 | 62.22% | 1 | 33.33% |
pre-git | pre-git | 34 | 37.78% | 2 | 66.67% |
| Total | 90 | 100.00% | 3 | 100.00% |
static int
heathrow_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
{
switch(device_id) {
case MB_FD:
case MB_FD1:
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_FLOPPY_ENABLE);
MB_BIS(bay, HEATHROW_FCR, HRW_SWIM_ENABLE);
return 0;
case MB_CD:
MB_BIC(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_IDE_ENABLE);
return 0;
case MB_PCI:
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_PCI_ENABLE);
return 0;
}
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 56 | 62.22% | 1 | 33.33% |
pre-git | pre-git | 34 | 37.78% | 2 | 66.67% |
| Total | 90 | 100.00% | 3 | 100.00% |
static int
keylargo_mb_setup_bus(struct media_bay_info* bay, u8 device_id)
{
switch(device_id) {
case MB_CD:
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
MB_BIC(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_ENABLE);
return 0;
case MB_PCI:
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_PCI_ENABLE);
return 0;
case MB_SOUND:
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_SOUND_ENABLE);
return 0;
}
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 65 | 74.71% | 1 | 33.33% |
pre-git | pre-git | 22 | 25.29% | 2 | 66.67% |
| Total | 87 | 100.00% | 3 | 100.00% |
/*
* Functions for tweaking resets
*/
static void
ohare_mb_un_reset(struct media_bay_info* bay)
{
MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 17 | 85.00% | 1 | 50.00% |
pre-git | pre-git | 3 | 15.00% | 1 | 50.00% |
| Total | 20 | 100.00% | 2 | 100.00% |
static void keylargo_mb_init(struct media_bay_info *bay)
{
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 18 | 90.00% | 1 | 50.00% |
paul mackerras | paul mackerras | 2 | 10.00% | 1 | 50.00% |
| Total | 20 | 100.00% | 2 | 100.00% |
static void heathrow_mb_un_reset(struct media_bay_info* bay)
{
MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 15 | 75.00% | 1 | 33.33% |
pre-git | pre-git | 3 | 15.00% | 1 | 33.33% |
benjamin herrenschmidt | benjamin herrenschmidt | 2 | 10.00% | 1 | 33.33% |
| Total | 20 | 100.00% | 3 | 100.00% |
static void keylargo_mb_un_reset(struct media_bay_info* bay)
{
MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 19 | 95.00% | 1 | 50.00% |
pre-git | pre-git | 1 | 5.00% | 1 | 50.00% |
| Total | 20 | 100.00% | 2 | 100.00% |
static void ohare_mb_un_reset_ide(struct media_bay_info* bay)
{
MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 15 | 75.00% | 1 | 50.00% |
pre-git | pre-git | 5 | 25.00% | 1 | 50.00% |
| Total | 20 | 100.00% | 2 | 100.00% |
static void heathrow_mb_un_reset_ide(struct media_bay_info* bay)
{
MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static void keylargo_mb_un_reset_ide(struct media_bay_info* bay)
{
MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static inline void set_mb_power(struct media_bay_info* bay, int onoff)
{
/* Power up up and assert the bay reset line */
if (onoff) {
bay->ops->power(bay, 1);
bay->state = mb_powering_up;
pr_debug("mediabay%d: powering up\n", bay->index);
} else {
/* Make sure everything is powered down & disabled */
bay->ops->power(bay, 0);
bay->state = mb_powering_down;
pr_debug("mediabay%d: powering down\n", bay->index);
}
bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 82 | 94.25% | 1 | 25.00% |
pre-git | pre-git | 2 | 2.30% | 1 | 25.00% |
benjamin herrenschmidt | benjamin herrenschmidt | 2 | 2.30% | 1 | 25.00% |
domen puncer | domen puncer | 1 | 1.15% | 1 | 25.00% |
| Total | 87 | 100.00% | 4 | 100.00% |
static void poll_media_bay(struct media_bay_info* bay)
{
int id = bay->ops->content(bay);
static char *mb_content_types[] = {
"a floppy drive",
"a floppy drive",
"an unsupported audio device",
"an ATA device",
"an unsupported PCI device",
"an unknown device",
};
if (id != bay->last_value) {
bay->last_value = id;
bay->value_count = 0;
return;
}
if (id == bay->content_id)
return;
bay->value_count += msecs_to_jiffies(MB_POLL_DELAY);
if (bay->value_count >= msecs_to_jiffies(MB_STABLE_DELAY)) {
/* If the device type changes without going thru
* "MB_NO", we force a pass by "MB_NO" to make sure
* things are properly reset
*/
if ((id != MB_NO) && (bay->content_id != MB_NO)) {
id = MB_NO;
pr_debug("mediabay%d: forcing MB_NO\n", bay->index);
}
pr_debug("mediabay%d: switching to %d\n", bay->index, id);
set_mb_power(bay, id != MB_NO);
bay->content_id = id;
if (id >= MB_NO || id < 0)
printk(KERN_INFO "mediabay%d: Bay is now empty\n", bay->index);
else
printk(KERN_INFO "mediabay%d: Bay contains %s\n",
bay->index, mb_content_types[id]);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 112 | 58.64% | 1 | 12.50% |
benjamin herrenschmidt | benjamin herrenschmidt | 67 | 35.08% | 2 | 25.00% |
pre-git | pre-git | 9 | 4.71% | 3 | 37.50% |
domen puncer | domen puncer | 2 | 1.05% | 1 | 12.50% |
masanari iida | masanari iida | 1 | 0.52% | 1 | 12.50% |
| Total | 191 | 100.00% | 8 | 100.00% |
int check_media_bay(struct macio_dev *baydev)
{
struct media_bay_info* bay;
int id;
if (baydev == NULL)
return MB_NO;
/* This returns an instant snapshot, not locking, sine
* we may be called with the bay lock held. The resulting
* fuzzyness of the result if called at the wrong time is
* not actually a huge deal
*/
bay = macio_get_drvdata(baydev);
if (bay == NULL)
return MB_NO;
id = bay->content_id;
if (bay->state != mb_up)
return MB_NO;
if (id == MB_FD1)
return MB_FD;
return id;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 46 | 63.01% | 1 | 50.00% |
paul mackerras | paul mackerras | 27 | 36.99% | 1 | 50.00% |
| Total | 73 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(check_media_bay);
void lock_media_bay(struct macio_dev *baydev)
{
struct media_bay_info* bay;
if (baydev == NULL)
return;
bay = macio_get_drvdata(baydev);
if (bay == NULL)
return;
mutex_lock(&bay->lock);
bay->user_lock = 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 36 | 72.00% | 2 | 40.00% |
paul mackerras | paul mackerras | 10 | 20.00% | 1 | 20.00% |
bartlomiej zolnierkiewicz | bartlomiej zolnierkiewicz | 3 | 6.00% | 1 | 20.00% |
daniel walker | daniel walker | 1 | 2.00% | 1 | 20.00% |
| Total | 50 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(lock_media_bay);
void unlock_media_bay(struct macio_dev *baydev)
{
struct media_bay_info* bay;
if (baydev == NULL)
return;
bay = macio_get_drvdata(baydev);
if (bay == NULL)
return;
if (bay->user_lock) {
bay->user_lock = 0;
mutex_unlock(&bay->lock);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 29 | 50.00% | 2 | 66.67% |
paul mackerras | paul mackerras | 29 | 50.00% | 1 | 33.33% |
| Total | 58 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(unlock_media_bay);
static int mb_broadcast_hotplug(struct device *dev, void *data)
{
struct media_bay_info* bay = data;
struct macio_dev *mdev;
struct macio_driver *drv;
int state;
if (dev->bus != &macio_bus_type)
return 0;
state = bay->state == mb_up ? bay->content_id : MB_NO;
if (state == MB_FD1)
state = MB_FD;
mdev = to_macio_device(dev);
drv = to_macio_driver(dev->driver);
if (dev->driver && drv->mediabay_event)
drv->mediabay_event(mdev, state);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 82 | 75.23% | 1 | 25.00% |
paul mackerras | paul mackerras | 23 | 21.10% | 1 | 25.00% |
pre-git | pre-git | 4 | 3.67% | 2 | 50.00% |
| Total | 109 | 100.00% | 4 | 100.00% |
static void media_bay_step(int i)
{
struct media_bay_info* bay = &media_bays[i];
/* We don't poll when powering down */
if (bay->state != mb_powering_down)
poll_media_bay(bay);
/* If timer expired run state machine */
if (bay->timer != 0) {
bay->timer -= msecs_to_jiffies(MB_POLL_DELAY);
if (bay->timer > 0)
return;
bay->timer = 0;
}
switch(bay->state) {
case mb_powering_up:
if (bay->ops->setup_bus(bay, bay->last_value) < 0) {
pr_debug("mediabay%d: device not supported (kind:%d)\n",
i, bay->content_id);
set_mb_power(bay, 0);
break;
}
bay->timer = msecs_to_jiffies(MB_RESET_DELAY);
bay->state = mb_enabling_bay;
pr_debug("mediabay%d: enabling (kind:%d)\n", i, bay->content_id);
break;
case mb_enabling_bay:
bay->ops->un_reset(bay);
bay->timer = msecs_to_jiffies(MB_SETUP_DELAY);
bay->state = mb_resetting;
pr_debug("mediabay%d: releasing bay reset (kind:%d)\n",
i, bay->content_id);
break;
case mb_resetting:
if (bay->content_id != MB_CD) {
pr_debug("mediabay%d: bay is up (kind:%d)\n", i,
bay->content_id);
bay->state = mb_up;
device_for_each_child(&bay->mdev->ofdev.dev,
bay, mb_broadcast_hotplug);
break;
}
pr_debug("mediabay%d: releasing ATA reset (kind:%d)\n",
i, bay->content_id);
bay->ops->un_reset_ide(bay);
bay->timer = msecs_to_jiffies(MB_IDE_WAIT);
bay->state = mb_ide_resetting;
break;
case mb_ide_resetting:
pr_debug("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id);
bay->state = mb_up;
device_for_each_child(&bay->mdev->ofdev.dev,
bay, mb_broadcast_hotplug);
break;
case mb_powering_down:
bay->state = mb_empty;
device_for_each_child(&bay->mdev->ofdev.dev,
bay, mb_broadcast_hotplug);
pr_debug("mediabay%d: end of power down\n", i);
break;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 223 | 66.17% | 3 | 27.27% |
pre-git | pre-git | 63 | 18.69% | 3 | 27.27% |
paul mackerras | paul mackerras | 43 | 12.76% | 2 | 18.18% |
bartlomiej zolnierkiewicz | bartlomiej zolnierkiewicz | 5 | 1.48% | 1 | 9.09% |
martin dalecki | martin dalecki | 2 | 0.59% | 1 | 9.09% |
domen puncer | domen puncer | 1 | 0.30% | 1 | 9.09% |
| Total | 337 | 100.00% | 11 | 100.00% |
/*
* This procedure runs as a kernel thread to poll the media bay
* once each tick and register and unregister the IDE interface
* with the IDE driver. It needs to be a thread because
* ide_register can't be called from interrupt context.
*/
static int media_bay_task(void *x)
{
int i;
while (!kthread_should_stop()) {
for (i = 0; i < media_bay_count; ++i) {
mutex_lock(&media_bays[i].lock);
if (!media_bays[i].sleeping)
media_bay_step(i);
mutex_unlock(&media_bays[i].lock);
}
msleep_interruptible(MB_POLL_DELAY);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 38 | 46.91% | 2 | 28.57% |
benjamin herrenschmidt | benjamin herrenschmidt | 35 | 43.21% | 2 | 28.57% |
pre-git | pre-git | 5 | 6.17% | 1 | 14.29% |
daniel walker | daniel walker | 2 | 2.47% | 1 | 14.29% |
domen puncer | domen puncer | 1 | 1.23% | 1 | 14.29% |
| Total | 81 | 100.00% | 7 | 100.00% |
static int media_bay_attach(struct macio_dev *mdev,
const struct of_device_id *match)
{
struct media_bay_info* bay;
u32 __iomem *regbase;
struct device_node *ofnode;
unsigned long base;
int i;
ofnode = mdev->ofdev.dev.of_node;
if (macio_resource_count(mdev) < 1)
return -ENODEV;
if (macio_request_resources(mdev, "media-bay"))
return -EBUSY;
/* Media bay registers are located at the beginning of the
* mac-io chip, for now, we trick and align down the first
* resource passed in
*/
base = macio_resource_start(mdev, 0) & 0xffff0000u;
regbase = (u32 __iomem *)ioremap(base, 0x100);
if (regbase == NULL) {
macio_release_resources(mdev);
return -ENOMEM;
}
i = media_bay_count++;
bay = &media_bays[i];
bay->mdev = mdev;
bay->base = regbase;
bay->index = i;
bay->ops = match->data;
bay->sleeping = 0;
mutex_init(&bay->lock);
/* Init HW probing */
if (bay->ops->init)
bay->ops->init(bay);
printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
/* Force an immediate detect */
set_mb_power(bay, 0);
msleep(MB_POWER_DELAY);
bay->content_id = MB_NO;
bay->last_value = bay->ops->content(bay);
bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
bay->state = mb_empty;
/* Mark us ready by filling our mdev data */
macio_set_drvdata(mdev, bay);
/* Startup kernel thread */
if (i == 0)
kthread_run(media_bay_task, NULL, "media-bay");
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 183 | 66.06% | 3 | 20.00% |
pre-git | pre-git | 46 | 16.61% | 4 | 26.67% |
paul mackerras | paul mackerras | 41 | 14.80% | 3 | 20.00% |
grant likely | grant likely | 3 | 1.08% | 1 | 6.67% |
jeff mahoney | jeff mahoney | 1 | 0.36% | 1 | 6.67% |
daniel walker | daniel walker | 1 | 0.36% | 1 | 6.67% |
domen puncer | domen puncer | 1 | 0.36% | 1 | 6.67% |
nishanth aravamudan | nishanth aravamudan | 1 | 0.36% | 1 | 6.67% |
| Total | 277 | 100.00% | 15 | 100.00% |
static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state)
{
struct media_bay_info *bay = macio_get_drvdata(mdev);
if (state.event != mdev->ofdev.dev.power.power_state.event
&& (state.event & PM_EVENT_SLEEP)) {
mutex_lock(&bay->lock);
bay->sleeping = 1;
set_mb_power(bay, 0);
mutex_unlock(&bay->lock);
msleep(MB_POLL_DELAY);
mdev->ofdev.dev.power.power_state = state;
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 71 | 70.30% | 2 | 20.00% |
paul mackerras | paul mackerras | 10 | 9.90% | 2 | 20.00% |
pavel machek | pavel machek | 7 | 6.93% | 2 | 20.00% |
art haas | art haas | 6 | 5.94% | 1 | 10.00% |
rafael j. wysocki | rafael j. wysocki | 4 | 3.96% | 1 | 10.00% |
daniel walker | daniel walker | 2 | 1.98% | 1 | 10.00% |
nishanth aravamudan | nishanth aravamudan | 1 | 0.99% | 1 | 10.00% |
| Total | 101 | 100.00% | 10 | 100.00% |
static int media_bay_resume(struct macio_dev *mdev)
{
struct media_bay_info *bay = macio_get_drvdata(mdev);
if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
mdev->ofdev.dev.power.power_state = PMSG_ON;
/* We re-enable the bay using it's previous content
only if it did not change. Note those bozo timings,
they seem to help the 3400 get it right.
*/
/* Force MB power to 0 */
mutex_lock(&bay->lock);
set_mb_power(bay, 0);
msleep(MB_POWER_DELAY);
if (bay->ops->content(bay) != bay->content_id) {
printk("mediabay%d: Content changed during sleep...\n", bay->index);
mutex_unlock(&bay->lock);
return 0;
}
set_mb_power(bay, 1);
bay->last_value = bay->content_id;
bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
do {
msleep(MB_POLL_DELAY);
media_bay_step(bay->index);
} while((bay->state != mb_empty) &&
(bay->state != mb_up));
bay->sleeping = 0;
mutex_unlock(&bay->lock);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 114 | 58.76% | 4 | 26.67% |
paul mackerras | paul mackerras | 39 | 20.10% | 2 | 13.33% |
pre-git | pre-git | 30 | 15.46% | 4 | 26.67% |
pavel machek | pavel machek | 4 | 2.06% | 2 | 13.33% |
daniel walker | daniel walker | 3 | 1.55% | 1 | 6.67% |
domen puncer | domen puncer | 2 | 1.03% | 1 | 6.67% |
nishanth aravamudan | nishanth aravamudan | 2 | 1.03% | 1 | 6.67% |
| Total | 194 | 100.00% | 15 | 100.00% |
/* Definitions of "ops" structures.
*/
static const struct mb_ops ohare_mb_ops = {
.name = "Ohare",
.content = ohare_mb_content,
.power = ohare_mb_power,
.setup_bus = ohare_mb_setup_bus,
.un_reset = ohare_mb_un_reset,
.un_reset_ide = ohare_mb_un_reset_ide,
};
static const struct mb_ops heathrow_mb_ops = {
.name = "Heathrow",
.content = heathrow_mb_content,
.power = heathrow_mb_power,
.setup_bus = heathrow_mb_setup_bus,
.un_reset = heathrow_mb_un_reset,
.un_reset_ide = heathrow_mb_un_reset_ide,
};
static const struct mb_ops keylargo_mb_ops = {
.name = "KeyLargo",
.init = keylargo_mb_init,
.content = keylargo_mb_content,
.power = keylargo_mb_power,
.setup_bus = keylargo_mb_setup_bus,
.un_reset = keylargo_mb_un_reset,
.un_reset_ide = keylargo_mb_un_reset_ide,
};
/*
* It seems that the bit for the media-bay interrupt in the IRQ_LEVEL
* register is always set when there is something in the media bay.
* This causes problems for the interrupt code if we attach an interrupt
* handler to the media-bay interrupt, because it tends to go into
* an infinite loop calling the media bay interrupt handler.
* Therefore we do it all by polling the media bay once each tick.
*/
static struct of_device_id media_bay_match[] =
{
{
.name = "media-bay",
.compatible = "keylargo-media-bay",
.data = &keylargo_mb_ops,
},
{
.name = "media-bay",
.compatible = "heathrow-media-bay",
.data = &heathrow_mb_ops,
},
{
.name = "media-bay",
.compatible = "ohare-media-bay",
.data = &ohare_mb_ops,
},
{},
};
static struct macio_driver media_bay_driver =
{
.driver = {
.name = "media-bay",
.of_match_table = media_bay_match,
},
.probe = media_bay_attach,
.suspend = media_bay_suspend,
.resume = media_bay_resume
};
static int __init media_bay_init(void)
{
int i;
for (i=0; i<MAX_BAYS; i++) {
memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
media_bays[i].content_id = -1;
}
if (!machine_is(powermac))
return 0;
macio_register_driver(&media_bay_driver);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
benjamin herrenschmidt | benjamin herrenschmidt | 61 | 78.21% | 2 | 33.33% |
paul mackerras | paul mackerras | 9 | 11.54% | 1 | 16.67% |
pre-git | pre-git | 8 | 10.26% | 3 | 50.00% |
| Total | 78 | 100.00% | 6 | 100.00% |
device_initcall(media_bay_init);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
paul mackerras | paul mackerras | 1274 | 40.61% | 4 | 10.81% |
benjamin herrenschmidt | benjamin herrenschmidt | 1209 | 38.54% | 7 | 18.92% |
pre-git | pre-git | 578 | 18.43% | 7 | 18.92% |
daniel walker | daniel walker | 13 | 0.41% | 1 | 2.70% |
bartlomiej zolnierkiewicz | bartlomiej zolnierkiewicz | 12 | 0.38% | 2 | 5.41% |
pavel machek | pavel machek | 11 | 0.35% | 3 | 8.11% |
domen puncer | domen puncer | 8 | 0.26% | 1 | 2.70% |
art haas | art haas | 6 | 0.19% | 1 | 2.70% |
christoph hellwig | christoph hellwig | 4 | 0.13% | 1 | 2.70% |
rafael j. wysocki | rafael j. wysocki | 4 | 0.13% | 1 | 2.70% |
nishanth aravamudan | nishanth aravamudan | 4 | 0.13% | 1 | 2.70% |
arnd bergmann | arnd bergmann | 3 | 0.10% | 1 | 2.70% |
grant likely | grant likely | 3 | 0.10% | 1 | 2.70% |
jeff mahoney | jeff mahoney | 2 | 0.06% | 1 | 2.70% |
martin dalecki | martin dalecki | 2 | 0.06% | 1 | 2.70% |
masanari iida | masanari iida | 1 | 0.03% | 1 | 2.70% |
al viro | al viro | 1 | 0.03% | 1 | 2.70% |
uwe kleine-koenig | uwe kleine-koenig | 1 | 0.03% | 1 | 2.70% |
linus torvalds | linus torvalds | 1 | 0.03% | 1 | 2.70% |
jon loeliger | jon loeliger | | 0.00% | 0 | 0.00% |
| Total | 3137 | 100.00% | 37 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.