|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" F1 W p9 f6 S8 B3 {
#include <linux/init.h>
/ v1 \: R, t9 P( [* o. e2 O" D+ ^#include <linux/module.h>
' m8 O. X* X% ^#include <linux/kernel.h>
c; O1 x J# o; o#include <linux/types.h>
: D& ^$ D6 |# H1 Y: G#include <linux/gpio.h>
: |6 ]- |4 k: o+ R4 C! f3 u- e+ D$ p#include <linux/leds.h>
9 W8 |& G- B" J1 V% ~, H#include <linux/platform_device.h>
# F5 B; ]8 Y5 T
4 e" f# J+ ]3 f, F#include <asm/mach-types.h>
8 b) O9 v! {+ d#include <asm/mach/arch.h>
2 _* U/ k2 w2 _6 m/ a#include <mach/da8xx.h>
; Q& t+ L. k" \7 z2 `2 f& t#include <mach/mux.h>! V- u1 b Q& Q
: c4 h E5 T5 ~3 y z- e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ A/ O: V7 R" P' j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: v' |% g$ J" h) a/ N1 R# v* l+ D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), P& P' m8 ~0 o% _2 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- H6 G H: ]' \" H; c. j# j
5 r. ?% m- Y* O/* assign the tl som board LED-GPIOs*/8 H, X7 _7 U1 c9 k, G3 {9 {: r D0 C
static const short da850_evm_tl_user_led_pins[] = {8 [$ K4 D& L1 ?+ q+ ]% R0 ^
/* These pins are definition at <mach/mux.h> file */
! o% m I6 P) C) j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; w" k: f% _$ l) G) y5 f1 F L" ~ -1/ h* \3 W- F9 x1 Z; i( {1 V( U% l
};- k6 s1 o7 y- W
# _/ a$ L3 F. l( k5 m; M. Jstatic struct gpio_led da850_evm_tl_leds[] = {8 s+ V& J8 K5 Z3 t, k5 f
{
! f- h1 N! S) e: h7 ~* R .active_low = 0,
% C0 r0 A- R$ w* o .gpio = DA850_USER_LED0,
& ^0 l( y2 m7 j$ W% L* {" f0 D2 B .name = "user_led0",
4 d8 |0 Z8 O B6 j$ M" s .default_trigger = "default-on",- e0 n* J4 e/ ^5 G6 q
},2 ?. o0 I, A9 _( q
{" t/ Q. K1 E0 E# H5 Z
.active_low = 0,
& O4 _" ~( A3 R% ]& M .gpio = DA850_USER_LED1,' V1 r \2 l: z& U3 W
.name = "user_led1",2 o. G* L% P \5 i( |( _
.default_trigger = "default-on",6 ^) H# @+ m" ^: c8 j* [0 s
},8 ?! P+ {7 a9 N3 q
{ s% x* A/ o% z9 _0 o- S! D
.active_low = 0,
h" ^4 J7 {+ w: h' O .gpio = DA850_USER_LED2,% o m( d9 P, t7 X, r2 U" w5 [
.name = "user_led2",
: R) `, ?$ a& {' p! b# b' } .default_trigger = "default-on",) }# y9 s7 _$ _- F8 j
},
6 Z" w1 z# D4 Y3 N. r' A {7 |& {* l. ]/ N, ?
.active_low = 0,# x4 T2 q- Z7 y2 a T; @, B& T b- { s
.gpio = DA850_USER_LED3," n i/ O' I# z Z! ^
.name = "user_led3",
0 s* |1 v) ~- \5 g/ w .default_trigger = "default-on",' m: @2 {4 B! Z4 o( f x8 W. G% z
},* n/ t& E3 {0 o) i1 S
};3 [4 z# k% n/ b* j) u
; q5 }1 S$ }, \% B3 E; ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 W: d" R" L) H2 T5 F/ z4 g
.leds = da850_evm_tl_leds,2 {/ l8 y6 h) f; V. S# K L, ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# w& |: [+ w0 R, G7 J
};' A# I: q% j& @% T# n' Z, ~/ Y
( l1 `( o' j. fstatic void led_dev_release(struct device *dev)$ q2 y, b3 X& a0 e6 |
{9 g4 {# c5 A+ b
};
; H* E% H" c7 I# b: B
' r! V: Y& T0 L1 P: e( p" Istatic struct platform_device da850_evm_tl_leds_device = {* L. v' i, E P6 ^5 R9 ?! m
.name = "leds-gpio",( T0 }* W$ e3 ?) ?% N9 S% b
.id = 1,
4 n; b4 A* T9 S5 p, Q" j .dev = {
! l+ s6 B: I! Q2 e* v1 U; l .platform_data = &da850_evm_tl_leds_pdata,: A7 W( A& s& c6 Z0 M
.release = led_dev_release,
: c/ }; S7 e3 n# S' a }
- T z; d3 V; D0 t! |6 q7 a}; Q9 x- d/ T- D( V$ @
! Y0 g/ \) o/ w2 y2 A
static int __init led_platform_init(void)
6 u8 z, d% }. a& t{
, X9 i. i* Q0 o4 ^ int ret;5 j3 V+ K) ]9 ~( B& ]* U- {& e8 a
#if 0
/ Z! O/ l3 y+ \0 F- Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
b+ p" a2 g5 Z: x. {& ? if (ret)
0 }. U" L% T, e, J+ p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# T$ h$ Z' l% z+ S& o3 I: Y% q- p2 W
"%d\n", ret);3 s! o; V2 W; g+ i& j
#endif9 ^! Q2 T% A4 ^$ I( Y
ret = platform_device_register(&da850_evm_tl_leds_device);
7 H0 K) e8 n5 g" l$ Q; ~- | if (ret)
$ k" Q; \; f+ N, V1 d% {" x, F pr_warning("Could not register som GPIO expander LEDS");
" C# B0 b- i. W w! n- q else
" T* v. F4 L1 q8 \. _ printk(KERN_INFO "LED register sucessful!\n");3 c0 ] j# C2 F: r" u" y
+ G9 R/ M% Z- z' l, y return ret;; \7 v" X+ @" z& y6 K
}
4 ~2 d% W x1 j6 t% _7 @# P' N% x! X& |+ p2 g9 g5 X! B
static void __exit led_platform_exit(void)
/ H" w" p' _2 ]{5 v! @( y0 m& I* q: t8 P
platform_device_unregister(&da850_evm_tl_leds_device);: N: g6 B& n+ e- V4 {5 e0 S
. y3 g" n% k: S& q# H4 O" P6 k printk(KERN_INFO "LED unregister!\n");; G& n- R e5 H8 ^' J
}
# h' V& D) v; o* y1 J7 O2 f& Z
/ }$ a @! \1 K) y. {module_init(led_platform_init);
* N7 g2 M: D3 b* b, fmodule_exit(led_platform_exit);! F4 B+ }" ^9 c/ ?% J4 { s
/ c. w8 ~, j3 a% T0 ?
MODULE_DESCRIPTION("Led platform driver");2 @0 Z% p& V( t* r! z: Z2 e
MODULE_AUTHOR("Tronlong");% [4 M+ y6 w% y
MODULE_LICENSE("GPL");
$ B* a1 ~ A. [8 N2 W5 [! `( Y, o: K- w6 ]! X$ b/ ` [
|
|