ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-loki-fan.c
1 /*
2  * arch/arm/mach-tegra/board-loki-fan.c
3  *
4  * Copyright (c) 2013 NVIDIA CORPORATION, All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/gpio.h>
21 #include <linux/platform_data/pwm_fan.h>
22 #include <linux/platform_device.h>
23
24 #include <mach/gpio-tegra.h>
25
26 #include "gpio-names.h"
27 #include "devices.h"
28 #include "board.h"
29 #include "board-common.h"
30 #include "board-loki.h"
31 #include "tegra-board-id.h"
32
33 static int active_pwm_loki[MAX_ACTIVE_STATES] = {
34                 0, 80*1024, 110*1024 , 150*1024, 200*1024, 240*1024,
35                 245*1024, 250*1024, 252*1024, 255*1024};
36
37 static int active_pwm_foster[MAX_ACTIVE_STATES] = {
38                 0, 70*1024, 115*1024 , 135*1024, 135*1024, 240*1024,
39                 245*1024, 250*1024, 252*1024, 255*1024};
40
41 static struct pwm_fan_platform_data fan_data_delta_6k = {
42         .active_steps = MAX_ACTIVE_STATES,
43         .active_rpm = {
44                 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 10000, 11000},
45         .active_rru = {1024*40, 1024*2, 1024, 256,
46                                                 256, 256, 256, 256, 256, 256},
47         .active_rrd = {1024*40, 1024*2, 1024, 256, 256,
48                                                 256, 256, 128, 128, 128},
49         .state_cap_lookup = {2, 2, 2, 2, 2, 2, 2, 3, 3, 3},
50         .pwm_period = 256,
51         .pwm_id = 0,
52         .step_time = 100, /*msecs*/
53         .state_cap = 7,
54         .precision_multiplier = 1024,
55         .tach_gpio = TEGRA_GPIO_PU2,
56         .pwm_gpio = TEGRA_GPIO_PU3,
57 };
58
59 static struct platform_device pwm_fan_therm_cooling_device_delta_6k = {
60         .name = "pwm-fan",
61         .id = -1,
62         .num_resources = 0,
63         .dev = {
64                 .platform_data = &fan_data_delta_6k,
65         },
66 };
67
68 int __init loki_fan_init(void)
69 {
70         int err;
71         struct board_info board_info;
72
73         tegra_get_board_info(&board_info);
74         if ((board_info.sku == 900) && (board_info.board_id == BOARD_P2530)) {
75                 memcpy((&fan_data_delta_6k)->active_pwm, &active_pwm_foster,
76                 sizeof(active_pwm_foster));
77         } else {
78                 memcpy((&fan_data_delta_6k)->active_pwm, &active_pwm_loki,
79                 sizeof(active_pwm_loki));
80         }
81
82         err = gpio_request(TEGRA_GPIO_PU3, "pwm-fan");
83         if (err < 0) {
84                 pr_err("FAN:gpio request failed\n");
85                 return err;
86         }
87
88         platform_device_register(
89                 &pwm_fan_therm_cooling_device_delta_6k);
90                         pr_info("Registering Fan!\n");
91         return 0;
92 }