|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) t9 b+ r. Z( F& T1 ~! f3 F1 G
#include <linux/init.h>; `9 X+ N( O- _% d- u
#include <linux/module.h>
& S$ I/ R9 m+ I. i#include <linux/kernel.h>% M" I) w' ?0 _
#include <linux/types.h>
" p: ~7 P2 n& ]# a* D1 N#include <linux/gpio.h>9 W" |( g3 h+ Y+ q! X+ v/ L
#include <linux/leds.h>, ~* H+ c% ]/ y
#include <linux/platform_device.h>
4 P% r4 A; ~8 P* K: [2 G1 h6 H$ }$ A h2 U* ~
#include <asm/mach-types.h>, K) e% h7 m/ f9 c" O
#include <asm/mach/arch.h>7 d7 w, H, t0 @, X
#include <mach/da8xx.h>
! P4 v5 X) u% Z( H3 o' `2 m#include <mach/mux.h>4 O9 H9 P* w8 Y- h4 a
1 @$ J+ Y/ m/ e( }. p, a- y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 J p- O- T" e2 S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). Y& S$ i# N8 M% a& `9 z' V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 O4 t" g4 A, F4 Y: C" d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 Q, ?9 N5 l; Y
) z/ }! e( Z( y" D/ W+ _$ j: |
/* assign the tl som board LED-GPIOs*/- T5 j u7 p) V7 c, m% A+ L
static const short da850_evm_tl_user_led_pins[] = {5 Q7 C' b/ U1 o" |- Z- ^0 H
/* These pins are definition at <mach/mux.h> file */) [/ `- ] p* j6 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- Q, R0 j: q0 @: v+ e b
-1$ W7 h8 D. ~3 y& d: L
};9 i3 s4 ?7 }. f- D& \
0 E) B6 M# {5 P. ^/ x" y# }5 b0 l
static struct gpio_led da850_evm_tl_leds[] = {9 H) N8 |9 Y& D% S! `5 Q
{; Q, ~! C5 H8 t" n
.active_low = 0,3 c7 V/ h* D7 A) f( C
.gpio = DA850_USER_LED0,
0 ^# b# X' U! f, C$ P h4 \ .name = "user_led0",
" e% X2 y1 C n" Z! H$ m, S .default_trigger = "default-on",
9 b u2 H. F1 B: k9 j },8 w e4 _( |: x2 \
{" U, ]/ B' `5 h# O
.active_low = 0,
3 w. M7 B- M) t .gpio = DA850_USER_LED1,' n$ a# S& D5 Y& e
.name = "user_led1",
3 V2 o* y! Q3 a2 Y |! g6 p9 L .default_trigger = "default-on",
6 J3 ^. k$ @) K% z2 ]; x) j },) d [' _2 x4 d5 i' ]
{
: c+ _4 D9 h" {# L3 b .active_low = 0,# F% T1 G; ~1 j% @5 \$ v- J/ q7 s
.gpio = DA850_USER_LED2,
3 S- |/ p1 l9 e) \- O( `+ e, j/ ?- L* S .name = "user_led2",5 n5 m5 U. ? R, m( v: B
.default_trigger = "default-on",% p E' `4 a1 {# r
},
& x+ k& ^3 ]9 P& [0 P {0 f$ `. ~+ E- Z3 F2 t$ J
.active_low = 0,8 m4 ]3 S, u0 ]0 D) u) x
.gpio = DA850_USER_LED3,% d0 p f( T: }8 F
.name = "user_led3",7 [6 h. P% g9 M- J" @' @
.default_trigger = "default-on",3 ^ n) K8 P. [1 w, Z
},
* R# b( `+ N+ t- k};: s1 g( J' X, ]; i4 E6 a
6 M. O0 s6 S3 O/ E" Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ h- S2 E1 i! S# c .leds = da850_evm_tl_leds,
8 S4 a9 Q4 R2 V, i" {, P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% x" |9 i9 ^8 B' {
};$ H! s: S# B: X) r
" g) y% r4 h4 N- A' h6 G/ I6 }; Qstatic void led_dev_release(struct device *dev)& V' B) q& K$ ?
{, @6 X x9 C5 o) Y3 Y9 R$ A
};! s2 S* K: y, P$ K+ Z# C
7 e: t8 t( ^$ v$ S/ n. x! w6 ^static struct platform_device da850_evm_tl_leds_device = {
# V! K6 Z% M9 V .name = "leds-gpio",% G: E6 ~3 p7 J$ j- r
.id = 1,2 O/ ^& N& A0 Q
.dev = {8 h* z$ U* o7 o
.platform_data = &da850_evm_tl_leds_pdata,7 Y$ R. g0 k) }. T, r0 _, r
.release = led_dev_release,, E$ |% q- x5 P" ^; V
}; i* k3 b: |4 x& L
};
, o& R, f9 Y: p6 F$ O
% v! q; D, ?$ k# V$ A4 Q# Z) cstatic int __init led_platform_init(void); I$ q: U; M9 C h
{
/ U+ h7 _" @. a8 ?1 U7 d7 f int ret;% s7 C( v3 H5 \
#if 0
, m( T# W6 O/ b6 o' q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 c) d8 p* M: p* O6 L+ D: s if (ret)- m+ Z2 e$ ]3 b4 t1 _' x9 c. C+ z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 c- e4 A1 Z" y/ W "%d\n", ret);% ] e. ?% Z* J# F( B9 D
#endif# i% a& i7 V4 @. ~
ret = platform_device_register(&da850_evm_tl_leds_device);- T! F" Q ^% ?- L
if (ret)
+ S' W' R; f% R! y! o8 V pr_warning("Could not register som GPIO expander LEDS");5 M5 X8 X& J5 }$ I. h
else
; r0 w" I- ^; d2 @4 ^ printk(KERN_INFO "LED register sucessful!\n");
/ v6 x! }: W: V$ \- Q' \- p. @" N% i$ Y
return ret;
8 `7 Z. s' D* f0 ?6 _, W3 ]# k} R; q7 S9 J2 ^$ @
; D: C/ c3 c- D- s& X2 x8 ]2 nstatic void __exit led_platform_exit(void)$ B3 d- X7 V7 W) q% X# L
{" ~' N: d9 k; D3 P* H: I- u
platform_device_unregister(&da850_evm_tl_leds_device);; l7 N" p* f% U: S6 }8 o: K
# J% k% u* ?: J9 X2 I( h- _ printk(KERN_INFO "LED unregister!\n");8 \: o4 ~% i @& |; W' f4 c
}0 b) x5 ^. T+ I+ _& N3 Z9 E9 @1 e
, j0 ] P H" p7 f% Emodule_init(led_platform_init);/ K2 K, A$ q1 f: L5 K2 G5 L
module_exit(led_platform_exit);
2 H1 h! z9 j1 C0 O5 J3 h7 p' l% E
$ p8 u" A9 Q* M5 z% YMODULE_DESCRIPTION("Led platform driver");
/ x$ ~& v* m: h5 X. j- ZMODULE_AUTHOR("Tronlong");
: j& ]+ I c& n1 N* b$ I1 {MODULE_LICENSE("GPL");
/ |! ^4 U5 U- e2 q! A3 h3 h1 f& i; S6 Y: J0 y
|
|