BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
fd386000
Commit
fd386000
authored
Aug 08, 2018
by
David Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backport features required for bq27xxx
The bq27xxx module now compiles for both 9x15 and 9x07 based targets. The module has not been tested yet.
parent
ee8e9a36
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
2 deletions
+174
-2
bq27xxx_battery.c
linux_kernel_modules/bq27xxx/bq27xxx_battery.c
+1
-1
bq27xxx_battery.mdef
linux_kernel_modules/bq27xxx/bq27xxx_battery.mdef
+2
-0
bq27xxx_battery_i2c.c
linux_kernel_modules/bq27xxx/bq27xxx_battery_i2c.c
+1
-1
bq27xxx_battery_i2c.mdef
linux_kernel_modules/bq27xxx/bq27xxx_battery_i2c.mdef
+1
-0
device_backport.h
linux_kernel_modules/bq27xxx/device_backport.h
+15
-0
devres_backport.c
linux_kernel_modules/bq27xxx/devres_backport.c
+65
-0
power_supply_backport.c
linux_kernel_modules/bq27xxx/power_supply_backport.c
+64
-0
power_supply_backport.h
linux_kernel_modules/bq27xxx/power_supply_backport.h
+25
-0
No files found.
linux_kernel_modules/bq27xxx/bq27xxx_battery.c
View file @
fd386000
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of.h>
#include
<linux/power/bq27xxx_battery.h>
#include
"bq27xxx_battery.h"
#define BQ27XXX_MANUFACTURER "Texas Instruments"
#define BQ27XXX_MANUFACTURER "Texas Instruments"
...
...
linux_kernel_modules/bq27xxx/bq27xxx_battery.mdef
View file @
fd386000
sources:
sources:
{
{
bq27xxx_battery.c
bq27xxx_battery.c
power_supply_backport.c
}
}
\ No newline at end of file
linux_kernel_modules/bq27xxx/bq27xxx_battery_i2c.c
View file @
fd386000
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <asm/unaligned.h>
#include <asm/unaligned.h>
#include
<linux/power/bq27xxx_battery.h>
#include
"bq27xxx_battery.h"
static
DEFINE_IDR
(
battery_id
);
static
DEFINE_IDR
(
battery_id
);
static
DEFINE_MUTEX
(
battery_mutex
);
static
DEFINE_MUTEX
(
battery_mutex
);
...
...
linux_kernel_modules/bq27xxx/bq27xxx_battery_i2c.mdef
View file @
fd386000
sources:
sources:
{
{
bq27xxx_battery_i2c.c
bq27xxx_battery_i2c.c
devres_backport.c
}
}
requires:
requires:
...
...
linux_kernel_modules/bq27xxx/device_backport.h
0 → 100644
View file @
fd386000
#ifndef DEVICE_BACKPORT_H
#define DEVICE_BACKPORT_H
#include <linux/compiler.h>
#include <linux/gfp.h>
/* Pulled from linux/compiler-gcc.h */
#define __malloc __attribute__((__malloc__))
extern
__printf
(
3
,
0
)
char
*
devm_kvasprintf
(
struct
device
*
dev
,
gfp_t
gfp
,
const
char
*
fmt
,
va_list
ap
)
__malloc
;
extern
__printf
(
3
,
4
)
char
*
devm_kasprintf
(
struct
device
*
dev
,
gfp_t
gfp
,
const
char
*
fmt
,
...)
__malloc
;
#endif
/* DEVICE_BACKPORT_H */
linux_kernel_modules/bq27xxx/devres_backport.c
0 → 100644
View file @
fd386000
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
#include <linux/slab.h>
#include <linux/device.h>
#include "device_backport.h"
/**
* devm_kvasprintf - Allocate resource managed space and format a string
* into that.
* @dev: Device to allocate memory for
* @gfp: the GFP mask used in the devm_kmalloc() call when
* allocating memory
* @fmt: The printf()-style format string
* @ap: Arguments for the format string
* RETURNS:
* Pointer to allocated string on success, NULL on failure.
*/
char
*
devm_kvasprintf
(
struct
device
*
dev
,
gfp_t
gfp
,
const
char
*
fmt
,
va_list
ap
)
{
unsigned
int
len
;
char
*
p
;
va_list
aq
;
va_copy
(
aq
,
ap
);
len
=
vsnprintf
(
NULL
,
0
,
fmt
,
aq
);
va_end
(
aq
);
p
=
devm_kmalloc
(
dev
,
len
+
1
,
gfp
);
if
(
!
p
)
return
NULL
;
vsnprintf
(
p
,
len
+
1
,
fmt
,
ap
);
return
p
;
}
EXPORT_SYMBOL
(
devm_kvasprintf
);
/**
* devm_kasprintf - Allocate resource managed space and format a string
* into that.
* @dev: Device to allocate memory for
* @gfp: the GFP mask used in the devm_kmalloc() call when
* allocating memory
* @fmt: The printf()-style format string
* @...: Arguments for the format string
* RETURNS:
* Pointer to allocated string on success, NULL on failure.
*/
char
*
devm_kasprintf
(
struct
device
*
dev
,
gfp_t
gfp
,
const
char
*
fmt
,
...)
{
va_list
ap
;
char
*
p
;
va_start
(
ap
,
fmt
);
p
=
devm_kvasprintf
(
dev
,
gfp
,
fmt
,
ap
);
va_end
(
ap
);
return
p
;
}
EXPORT_SYMBOL_GPL
(
devm_kasprintf
);
#endif
/* LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) */
linux_kernel_modules/bq27xxx/power_supply_backport.c
0 → 100644
View file @
fd386000
/*
* This file contains backported features of the power supply subsystem from 4.18-rc8
*/
#include <linux/device.h>
#include <linux/of.h>
#include <linux/power_supply.h>
#include "power_supply_backport.h"
int
power_supply_get_battery_info
(
struct
power_supply
*
psy
,
struct
power_supply_battery_info
*
info
)
{
struct
device_node
*
battery_np
;
const
char
*
value
;
int
err
;
info
->
energy_full_design_uwh
=
-
EINVAL
;
info
->
charge_full_design_uah
=
-
EINVAL
;
info
->
voltage_min_design_uv
=
-
EINVAL
;
info
->
precharge_current_ua
=
-
EINVAL
;
info
->
charge_term_current_ua
=
-
EINVAL
;
info
->
constant_charge_current_max_ua
=
-
EINVAL
;
info
->
constant_charge_voltage_max_uv
=
-
EINVAL
;
if
(
!
psy
->
of_node
)
{
dev_warn
(
psy
->
dev
,
"%s currently only supports devicetree
\n
"
,
__func__
);
return
-
ENXIO
;
}
battery_np
=
of_parse_phandle
(
psy
->
of_node
,
"monitored-battery"
,
0
);
if
(
!
battery_np
)
return
-
ENODEV
;
err
=
of_property_read_string
(
battery_np
,
"compatible"
,
&
value
);
if
(
err
)
return
err
;
if
(
strcmp
(
"simple-battery"
,
value
))
return
-
ENODEV
;
/* The property and field names below must correspond to elements
* in enum power_supply_property. For reasoning, see
* Documentation/power/power_supply_class.txt.
*/
of_property_read_u32
(
battery_np
,
"energy-full-design-microwatt-hours"
,
&
info
->
energy_full_design_uwh
);
of_property_read_u32
(
battery_np
,
"charge-full-design-microamp-hours"
,
&
info
->
charge_full_design_uah
);
of_property_read_u32
(
battery_np
,
"voltage-min-design-microvolt"
,
&
info
->
voltage_min_design_uv
);
of_property_read_u32
(
battery_np
,
"precharge-current-microamp"
,
&
info
->
precharge_current_ua
);
of_property_read_u32
(
battery_np
,
"charge-term-current-microamp"
,
&
info
->
charge_term_current_ua
);
of_property_read_u32
(
battery_np
,
"constant_charge_current_max_microamp"
,
&
info
->
constant_charge_current_max_ua
);
of_property_read_u32
(
battery_np
,
"constant_charge_voltage_max_microvolt"
,
&
info
->
constant_charge_voltage_max_uv
);
return
0
;
}
EXPORT_SYMBOL_GPL
(
power_supply_get_battery_info
);
linux_kernel_modules/bq27xxx/power_supply_backport.h
0 → 100644
View file @
fd386000
#ifndef POWER_SUPPLY_BACKPORT_H
#define POWER_SUPPLY_BACKPORT_H
/*
* This is the recommended struct to manage static battery parameters,
* populated by power_supply_get_battery_info(). Most platform drivers should
* use these for consistency.
* Its field names must correspond to elements in enum power_supply_property.
* The default field value is -EINVAL.
* Power supply class itself doesn't use this.
*/
struct
power_supply_battery_info
{
int
energy_full_design_uwh
;
/* microWatt-hours */
int
charge_full_design_uah
;
/* microAmp-hours */
int
voltage_min_design_uv
;
/* microVolts */
int
precharge_current_ua
;
/* microAmps */
int
charge_term_current_ua
;
/* microAmps */
int
constant_charge_current_max_ua
;
/* microAmps */
int
constant_charge_voltage_max_uv
;
/* microVolts */
};
extern
int
power_supply_get_battery_info
(
struct
power_supply
*
psy
,
struct
power_supply_battery_info
*
info
);
#endif
/* POWER_SUPPLY_BACKPORT_H */
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