Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
33ea3a3f
Commit
33ea3a3f
authored
Sep 07, 2014
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greybus: add battery module
parent
43cc32a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
1 deletion
+167
-1
drivers/staging/greybus/Makefile
drivers/staging/greybus/Makefile
+2
-1
drivers/staging/greybus/battery-gb.c
drivers/staging/greybus/battery-gb.c
+153
-0
drivers/staging/greybus/core.c
drivers/staging/greybus/core.c
+8
-0
drivers/staging/greybus/greybus.h
drivers/staging/greybus/greybus.h
+4
-0
No files found.
drivers/staging/greybus/Makefile
View file @
33ea3a3f
...
...
@@ -6,7 +6,8 @@ greybus-y := core.o \
i2c-gb.o
\
gpio-gb.o
\
sdio-gb.o
\
uart-gb.o
uart-gb.o
\
battery-gb.o
obj-m
+=
greybus.o
obj-m
+=
es1-ap-usb.o
...
...
drivers/staging/greybus/battery-gb.c
0 → 100644
View file @
33ea3a3f
/*
* Battery driver for a Greybus module.
*
* Copyright 2014 Google Inc.
*
* Released under the GPLv2 only.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/power_supply.h>
#include "greybus.h"
struct
gb_battery
{
struct
power_supply
bat
;
struct
greybus_device
*
gdev
;
};
#define to_gb_battery(x) container_of(x, struct gb_battery, bat)
static
const
struct
greybus_module_id
id_table
[]
=
{
{
GREYBUS_DEVICE
(
0x42
,
0x42
)
},
/* make shit up */
{
},
/* terminating NULL entry */
};
static
int
get_status
(
struct
gb_battery
*
gb
)
{
// FIXME!!!
return
0
;
}
static
int
get_capacity
(
struct
gb_battery
*
gb
)
{
// FIXME!!!
return
0
;
}
static
int
get_temp
(
struct
gb_battery
*
gb
)
{
// FIXME!!!
return
0
;
}
static
int
get_voltage
(
struct
gb_battery
*
gb
)
{
// FIXME!!!
return
0
;
}
static
int
get_property
(
struct
power_supply
*
b
,
enum
power_supply_property
psp
,
union
power_supply_propval
*
val
)
{
struct
gb_battery
*
gb
=
to_gb_battery
(
b
);
switch
(
psp
)
{
case
POWER_SUPPLY_PROP_TECHNOLOGY
:
// FIXME - guess!
val
->
intval
=
POWER_SUPPLY_TECHNOLOGY_NiMH
;
break
;
case
POWER_SUPPLY_PROP_STATUS
:
val
->
intval
=
get_status
(
gb
);
break
;
case
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN
:
val
->
intval
=
4700000
;
// FIXME - guess???
break
;
case
POWER_SUPPLY_PROP_CAPACITY
:
val
->
intval
=
get_capacity
(
gb
);
break
;
case
POWER_SUPPLY_PROP_TEMP
:
val
->
intval
=
get_temp
(
gb
);
break
;
case
POWER_SUPPLY_PROP_VOLTAGE_NOW
:
val
->
intval
=
get_voltage
(
gb
);
break
;
default:
return
-
EINVAL
;
}
return
0
;
}
// FIXME - verify this list, odds are some can be removed and others added.
static
enum
power_supply_property
battery_props
[]
=
{
POWER_SUPPLY_PROP_TECHNOLOGY
,
POWER_SUPPLY_PROP_STATUS
,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN
,
POWER_SUPPLY_PROP_CAPACITY
,
POWER_SUPPLY_PROP_TEMP
,
POWER_SUPPLY_PROP_VOLTAGE_NOW
,
};
int
gb_battery_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_module_id
*
id
)
{
struct
gb_battery
*
gb
;
struct
power_supply
*
b
;
int
retval
;
gb
=
kzalloc
(
sizeof
(
*
gb
),
GFP_KERNEL
);
if
(
!
gb
)
return
-
ENOMEM
;
b
=
&
gb
->
bat
;
// FIXME - get a better (i.e. unique) name
// FIXME - anything else needs to be set?
b
->
name
=
"gb_battery"
;
b
->
type
=
POWER_SUPPLY_TYPE_BATTERY
,
b
->
properties
=
battery_props
,
b
->
num_properties
=
ARRAY_SIZE
(
battery_props
),
b
->
get_property
=
get_property
,
retval
=
power_supply_register
(
&
gdev
->
dev
,
b
);
if
(
retval
)
{
kfree
(
gb
);
return
retval
;
}
gdev
->
gb_battery
=
gb
;
return
0
;
}
void
gb_battery_disconnect
(
struct
greybus_device
*
gdev
)
{
struct
gb_battery
*
gb
;
gb
=
gdev
->
gb_battery
;
power_supply_unregister
(
&
gb
->
bat
);
kfree
(
gb
);
}
#if 0
static struct greybus_driver battery_gb_driver = {
.probe = gb_battery_probe,
.disconnect = gb_battery_disconnect,
.id_table = id_table,
};
module_greybus_driver(battery_gb_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");
#endif
drivers/staging/greybus/core.c
View file @
33ea3a3f
...
...
@@ -210,8 +210,15 @@ static int gb_init_subdevs(struct greybus_device *gdev,
retval
=
gb_tty_probe
(
gdev
,
id
);
if
(
retval
)
goto
error_tty
;
retval
=
gb_battery_probe
(
gdev
,
id
);
if
(
retval
)
goto
error_battery
;
return
0
;
error_battery:
gb_tty_disconnect
(
gdev
);
error_tty:
gb_sdio_disconnect
(
gdev
);
...
...
@@ -444,6 +451,7 @@ void greybus_remove_device(struct greybus_device *gdev)
gb_gpio_disconnect
(
gdev
);
gb_sdio_disconnect
(
gdev
);
gb_tty_disconnect
(
gdev
);
gb_battery_disconnect
(
gdev
);
// FIXME - device_remove(&gdev->dev);
}
...
...
drivers/staging/greybus/greybus.h
View file @
33ea3a3f
...
...
@@ -91,6 +91,7 @@ struct gb_gpio_device;
struct
gb_sdio_host
;
struct
gb_tty
;
struct
gb_usb_device
;
struct
gb_battery
;
struct
greybus_host_device
;
struct
svc_msg
;
...
...
@@ -142,6 +143,7 @@ struct greybus_device {
struct
gb_sdio_host
*
gb_sdio_host
;
struct
gb_tty
*
gb_tty
;
struct
gb_usb_device
*
gb_usb_dev
;
struct
gb_battery
*
gb_battery
;
};
#define to_greybus_device(d) container_of(d, struct greybus_device, dev)
...
...
@@ -237,6 +239,8 @@ int gb_sdio_probe(struct greybus_device *gdev, const struct greybus_module_id *i
void
gb_sdio_disconnect
(
struct
greybus_device
*
gdev
);
int
gb_tty_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_module_id
*
id
);
void
gb_tty_disconnect
(
struct
greybus_device
*
gdev
);
int
gb_battery_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_module_id
*
id
);
void
gb_battery_disconnect
(
struct
greybus_device
*
gdev
);
int
gb_tty_init
(
void
);
void
gb_tty_exit
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment