blob: 71bfd6bbfff8e9d71f0eed2ef068de7626ba5a1e [file] [log] [blame]
Martijn Coenen44ae5b22011-11-02 16:09:37 -07001/*
2 * Copyright (C) 2011 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 <errno.h>
Elliott Hughes07c08552015-01-29 21:19:10 -080017#include <malloc.h>
Martijn Coenen44ae5b22011-11-02 16:09:37 -070018#include <string.h>
19
20#include <hardware/hardware.h>
21#include <hardware/nfc.h>
22
23/* Close an opened pn544 device instance */
24static int pn544_close(hw_device_t *dev) {
25 free(dev);
26 return 0;
27}
28
29/*
30 * Generic device handling
31 */
32static int nfc_open(const hw_module_t* module, const char* name,
33 hw_device_t** device) {
34 if (strcmp(name, NFC_PN544_CONTROLLER) == 0) {
35 nfc_pn544_device_t *dev = calloc(1, sizeof(nfc_pn544_device_t));
36
37 dev->common.tag = HARDWARE_DEVICE_TAG;
38 dev->common.version = 0;
39 dev->common.module = (struct hw_module_t*) module;
40 dev->common.close = pn544_close;
41
42 /* Example settings */
43 dev->num_eeprom_settings = 0;
44 dev->eeprom_settings = NULL;
45 dev->linktype = PN544_LINK_TYPE_INVALID;
46 dev->device_node = NULL;
47 dev->enable_i2c_workaround = 0;
Rakesh Goyal4cbd62c2012-01-27 18:13:29 +053048 dev->i2c_device_address = 0;
Martijn Coenen44ae5b22011-11-02 16:09:37 -070049
50 *device = (hw_device_t*) dev;
51 return 0;
52 } else {
53 return -EINVAL;
54 }
55}
56
57
58static struct hw_module_methods_t nfc_module_methods = {
59 .open = nfc_open,
60};
61
62struct nfc_module_t HAL_MODULE_INFO_SYM = {
63 .common = {
64 .tag = HARDWARE_MODULE_TAG,
65 .version_major = 1,
66 .version_minor = 0,
67 .id = NFC_HARDWARE_MODULE_ID,
68 .name = "Default NFC HW HAL",
69 .author = "The Android Open Source Project",
70 .methods = &nfc_module_methods,
71 },
72};