Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux linaro lsk v3.14 mx6 thermal #24

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3f41dc2
thermal: Add braces around suspect code
bebarino Jun 18, 2014
f16fa8e
thermal: Bind cooling devices with the correct arguments
punitagrawal Jun 3, 2014
2b1601b
thermal: imx: update formula for thermal sensor
Feb 12, 2014
1d484d2
Thermal: imx: correct critical trip temperature setting
Jun 20, 2014
d735911
thermal: trace: Trace temperature changes
punitagrawal Jul 29, 2014
fbdc9d6
thermal: trace: Trace when a cooling device's state is updated
punitagrawal Jul 29, 2014
458d18c
thermal: trace: Trace when temperature is above a trip point
punitagrawal Jul 29, 2014
dbf8e94
Thermal:Remove usless if(!result) before return tz
Oct 28, 2014
2c61c01
thermal: imx: correct driver load sequence for cpu cooling
Oct 14, 2014
3694c1a
thermal: imx_thermal: Second cooling device uses devfreq driver
linux4kix Nov 26, 2014
8398747
thermal: imx_thermal: re-org the _probe function to fix unbalanced in…
linux4kix Nov 26, 2014
d748dbb
thermal: imx_thermal: Add a trip point for each cpu_freq state
linux4kix Nov 26, 2014
9963c50
thermal: step_wise: Add and fix debug output
linux4kix Nov 26, 2014
d971414
thermal: devfreq_cooling: Allow max_states to be variable
linux4kix Nov 26, 2014
72fe282
thermal: imx_thermal: Set max_events for devfreq_cooling
linux4kix Nov 26, 2014
0424f6a
gpu: galcore: Handle additional cooling information
linux4kix Nov 26, 2014
4e02d4b
char: fsl_otp: Enable kernel config option to enable write support
linux4kix Dec 17, 2014
5e36f29
char: fsl_otp: Add function to read otp values
linux4kix Dec 17, 2014
c019307
mach: imx: Use fsl_otp helper function
linux4kix Dec 17, 2014
212c17d
thermal: imx: Rework driver for better flexibility
linux4kix Dec 17, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 12 additions & 36 deletions arch/arm/mach-imx/mach-imx6q.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/of_net.h>
#include <linux/fsl_otp.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/system_misc.h>
Expand Down Expand Up @@ -230,11 +231,11 @@ static void __init imx6q_csi_mux_init(void)
#define OCOTP_MACn(n) (0x00000620 + (n) * 0x10)
void __init imx6_enet_mac_init(const char *compatible)
{
struct device_node *ocotp_np, *enet_np;
void __iomem *base;
struct device_node *enet_np;
struct property *newmac;
u32 macaddr_low, macaddr_high;
u8 *macaddr;
int ret;

enet_np = of_find_compatible_node(NULL, NULL, compatible);
if (!enet_np)
Expand All @@ -243,31 +244,19 @@ void __init imx6_enet_mac_init(const char *compatible)
if (of_get_mac_address(enet_np))
goto put_enet_node;

ocotp_np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
if (!ocotp_np) {
pr_warn("failed to find ocotp node\n");
goto put_enet_node;
}

base = of_iomap(ocotp_np, 0);
if (!base) {
pr_warn("failed to map ocotp\n");
goto put_ocotp_node;
}

macaddr_high = readl_relaxed(base + OCOTP_MACn(0));
macaddr_low = readl_relaxed(base + OCOTP_MACn(1));
ret = fsl_otp_readl(OCOTP_MACn(0), &macaddr_high);
ret = fsl_otp_readl(OCOTP_MACn(1), &macaddr_low);

newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
if (!newmac)
goto put_ocotp_node;
goto put_enet_node;

newmac->value = newmac + 1;
newmac->length = 6;
newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
if (!newmac->name) {
kfree(newmac);
goto put_ocotp_node;
goto put_enet_node;
}

macaddr = newmac->value;
Expand All @@ -280,8 +269,6 @@ void __init imx6_enet_mac_init(const char *compatible)

of_update_property(enet_np, newmac);

put_ocotp_node:
of_node_put(ocotp_np);
put_enet_node:
of_node_put(enet_np);
}
Expand Down Expand Up @@ -323,20 +310,13 @@ static void __init imx6q_init_machine(void)

static void __init imx6q_opp_check_speed_grading(struct device *cpu_dev)
{
struct device_node *np;
void __iomem *base;
u32 val;
int ret;

np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
if (!np) {
pr_warn("failed to find ocotp node\n");
return;
}

base = of_iomap(np, 0);
if (!base) {
pr_warn("failed to map ocotp\n");
goto put_node;
ret = fsl_otp_readl(OCOTP_CFG3, &val);
if (ret) {
pr_warn("failed to read ocotp\n");
return;
}

/*
Expand All @@ -348,7 +328,6 @@ static void __init imx6q_opp_check_speed_grading(struct device *cpu_dev)
* We need to set the max speed of ARM according to fuse map.
*/

val = readl_relaxed(base + OCOTP_CFG3);
val >>= OCOTP_CFG3_SPEED_SHIFT;
if (cpu_is_imx6q()) {
if ((val & 0x3) < OCOTP_CFG3_SPEED_1P2GHZ)
Expand All @@ -364,9 +343,6 @@ static void __init imx6q_opp_check_speed_grading(struct device *cpu_dev)
if (dev_pm_opp_disable(cpu_dev, 852000000))
pr_warn("failed to disable 850 MHz OPP\n");
}

put_node:
of_node_put(np);
}

static void __init imx6q_opp_init(void)
Expand Down
33 changes: 25 additions & 8 deletions drivers/char/fsl_otp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/fsl_otp.h>

#define HW_OCOTP_CTRL 0x00000000
#define HW_OCOTP_CTRL_SET 0x00000004
Expand Down Expand Up @@ -125,16 +126,13 @@ static int otp_wait_busy(u32 flags)
return 0;
}

static ssize_t fsl_otp_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
int fsl_otp_readl(unsigned long offset, u32 *value)
{
unsigned int index = attr - otp_kattr;
u32 value = 0;
int ret;
int ret = 0;

ret = clk_prepare_enable(otp_clk);
if (ret)
return 0;
return ret;

mutex_lock(&otp_mutex);

Expand All @@ -143,14 +141,28 @@ static ssize_t fsl_otp_show(struct kobject *kobj, struct kobj_attribute *attr,
if (ret)
goto out;

value = __raw_readl(otp_base + HW_OCOTP_CUST_N(index));
*value = __raw_readl(otp_base + offset);

out:
mutex_unlock(&otp_mutex);
clk_disable_unprepare(otp_clk);
return ret;
}
EXPORT_SYMBOL(fsl_otp_readl);

static ssize_t fsl_otp_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
unsigned int index = attr - otp_kattr;
u32 value = 0;
int ret;

ret = fsl_otp_readl(HW_OCOTP_CUST_N(index), &value);

return ret ? 0 : sprintf(buf, "0x%x\n", value);
}

#ifdef CONFIG_FSL_OTP_WRITE_ENABLE
static int otp_write_bits(int addr, u32 data, u32 magic)
{
u32 c; /* for control register */
Expand Down Expand Up @@ -204,6 +216,7 @@ static ssize_t fsl_otp_store(struct kobject *kobj, struct kobj_attribute *attr,
clk_disable_unprepare(otp_clk);
return ret ? 0 : count;
}
#endif

static int fsl_otp_probe(struct platform_device *pdev)
{
Expand Down Expand Up @@ -244,9 +257,13 @@ static int fsl_otp_probe(struct platform_device *pdev)
for (i = 0; i < num; i++) {
sysfs_attr_init(&otp_kattr[i].attr);
otp_kattr[i].attr.name = desc[i];
#ifdef CONFIG_FSL_OTP_WRITE_ENABLE
otp_kattr[i].attr.mode = 0600;
otp_kattr[i].show = fsl_otp_show;
otp_kattr[i].store = fsl_otp_store;
#else
otp_kattr[i].attr.mode = 0400;
#endif
otp_kattr[i].show = fsl_otp_show;
attrs[i] = &otp_kattr[i].attr;
}
otp_attr_group->attrs = attrs;
Expand Down
19 changes: 12 additions & 7 deletions drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,18 +1032,23 @@ static int thermal_hot_pm_notify(struct notifier_block *nb, unsigned long event,
void *dummy)
{
static gctUINT orgFscale, minFscale, maxFscale;
static gctBOOL bAlreadyTooHot = gcvFALSE;
static gctBOOL critical;
gckHARDWARE hardware = galDevice->kernels[gcvCORE_MAJOR]->hardware;

if (event && !bAlreadyTooHot) {
if (event > 4) {
critical = gcvTRUE;
gckHARDWARE_GetFscaleValue(hardware,&orgFscale,&minFscale, &maxFscale);
gckHARDWARE_SetFscaleValue(hardware, minFscale);
bAlreadyTooHot = gcvTRUE;
gckOS_Print("System is too hot. GPU3D will work at %d/64 clock.\n", minFscale);
} else if (!event && bAlreadyTooHot) {
gckOS_Print("System is too hot. GPU3D scalign to %d/64 clock.\n", minFscale);
} else if (event > 1) {
gckHARDWARE_GetFscaleValue(hardware,&orgFscale,&minFscale, &maxFscale);
gckHARDWARE_SetFscaleValue(hardware, maxFscale - (8 * event));
} else if (orgFscale) {
gckHARDWARE_SetFscaleValue(hardware, orgFscale);
gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale);
bAlreadyTooHot = gcvFALSE;
if (critical) {
gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale);
critical = gcvFALSE;
}
}
return NOTIFY_OK;
}
Expand Down
16 changes: 11 additions & 5 deletions drivers/thermal/device_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ struct devfreq_cooling_device {
int id;
struct thermal_cooling_device *cool_dev;
unsigned int devfreq_state;
unsigned int max_state;
};

static DEFINE_IDR(devfreq_idr);
static DEFINE_MUTEX(devfreq_cooling_lock);

#define MAX_STATE 1

static BLOCKING_NOTIFIER_HEAD(devfreq_cooling_chain_head);

int register_devfreq_cooling_notifier(struct notifier_block *nb)
Expand Down Expand Up @@ -51,8 +50,13 @@ static int devfreq_set_cur_state(struct thermal_cooling_device *cdev,
{
struct devfreq_cooling_device *devfreq_device = cdev->devdata;
int ret;
unsigned long notify_state;

ret = devfreq_cooling_notifier_call_chain(state);
if (state >= devfreq_device->max_state)
notify_state = 5;
else
notify_state = state;
ret = devfreq_cooling_notifier_call_chain(notify_state);
if (ret)
return -EINVAL;
devfreq_device->devfreq_state = state;
Expand All @@ -63,7 +67,8 @@ static int devfreq_set_cur_state(struct thermal_cooling_device *cdev,
static int devfreq_get_max_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{
*state = MAX_STATE;
struct devfreq_cooling_device *devfreq_device = cdev->devdata;
*state = devfreq_device->max_state;

return 0;
}
Expand Down Expand Up @@ -105,7 +110,7 @@ static void release_idr(struct idr *idr, int id)
mutex_unlock(&devfreq_cooling_lock);
}

struct thermal_cooling_device *devfreq_cooling_register(void)
struct thermal_cooling_device *devfreq_cooling_register(unsigned long max_state)
{
struct thermal_cooling_device *cool_dev;
struct devfreq_cooling_device *devfreq_dev = NULL;
Expand Down Expand Up @@ -135,6 +140,7 @@ struct thermal_cooling_device *devfreq_cooling_register(void)
}
devfreq_dev->cool_dev = cool_dev;
devfreq_dev->devfreq_state = 0;
devfreq_dev->max_state = max_state;

return cool_dev;
}
Expand Down
12 changes: 12 additions & 0 deletions drivers/thermal/fair_share.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#include <linux/thermal.h>
#include <trace/events/thermal.h>

#include "thermal_core.h"

Expand All @@ -34,6 +35,7 @@ static int get_trip_level(struct thermal_zone_device *tz)
{
int count = 0;
unsigned long trip_temp;
enum thermal_trip_type trip_type;

if (tz->trips == 0 || !tz->ops->get_trip_temp)
return 0;
Expand All @@ -43,6 +45,16 @@ static int get_trip_level(struct thermal_zone_device *tz)
if (tz->temperature < trip_temp)
break;
}

/*
* count > 0 only if temperature is greater than first trip
* point, in which case, trip_point = count - 1
*/
if (count > 0) {
tz->ops->get_trip_type(tz, count - 1, &trip_type);
trace_thermal_zone_trip(tz, count - 1, trip_type);
}

return count;
}

Expand Down
Loading