blob: 2dc1eb3a265d39e3cc688ee1d18245d9b5c8e5c1 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <stdlib.h>
17#include <fcntl.h>
18#include <errno.h>
19#include <string.h>
20
21#include <cutils/properties.h>
22#define LOG_TAG "TiwlanWifiController"
23#include <cutils/log.h>
24
25#include "TiwlanWifiController.h"
26
27#define DRIVER_PROP_NAME "wlan.driver.status"
28
29extern "C" int sched_yield(void);
30
31TiwlanWifiController::TiwlanWifiController(char *modpath, char *modname, char *modargs) :
32 WifiController(modpath, modname, modargs) {
33}
34
35int TiwlanWifiController::powerUp() {
36 return 0; // Powerup is currently done when the driver is loaded
37}
38
39int TiwlanWifiController::powerDown() {
40 return 0; // Powerdown is currently done when the driver is unloaded
41}
42
43bool TiwlanWifiController::isPoweredUp() {
44 return isKernelModuleLoaded(getModuleName());
45}
46
47int TiwlanWifiController::loadFirmware() {
48 char driver_status[PROPERTY_VALUE_MAX];
49 int count = 100;
50
51 LOGD("loadFirmware()");
52 property_set("ctl.start", "wlan_loader");
53 sched_yield();
54
55 // Wait for driver to be ready
56 while (count-- > 0) {
57 if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
58 if (strcmp(driver_status, "ok") == 0)
59 return 0;
60 else if (strcmp(DRIVER_PROP_NAME, "failed") == 0)
61 return -1;
62 }
63 usleep(200000);
64 }
65 property_set(DRIVER_PROP_NAME, "timeout");
66 return -1;
67}
San Mehat1441e762009-05-07 11:37:10 -070068
69bool TiwlanWifiController::isFirmwareLoaded() {
San Mehat69772dc2009-05-10 09:27:07 -070070 // Always load the firmware
San Mehat1441e762009-05-07 11:37:10 -070071 return false;
72}