|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ [" W B3 t: \6 z- B4 v H( m
#include <linux/init.h>7 T) [- A! X7 B
#include <linux/module.h>
5 g6 }# [! ?7 G# [4 k( M#include <linux/kernel.h>
' L2 d6 M9 |# Y! I. s% W I#include <linux/types.h>
5 d* v3 p) T4 o#include <linux/gpio.h>
1 k7 i" f% K8 M, \6 H) E# D#include <linux/leds.h>
& J1 ^; h$ s3 r4 P( A& x5 {#include <linux/platform_device.h>* U, Y' F9 U& d9 x4 a, Y0 s) K
4 {) I; O: Q! b. U# W7 P
#include <asm/mach-types.h>
' e, w+ h/ N' I7 z, o. D m. k#include <asm/mach/arch.h>
0 w+ s; W6 T) e- [6 i#include <mach/da8xx.h>
9 d0 B% ]5 y: Q V+ P* a# m" {#include <mach/mux.h>9 J2 A0 Y2 v& F; Y" B, G
9 V9 h) h7 u( T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( {9 X' W0 I! F. |8 m. g2 q$ w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ Q/ t1 s7 P2 q- ?+ R Z0 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 b+ D: K& B3 w2 H# L0 U, N" N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! Q3 }, @8 }, I4 r- | S2 ]% L2 N3 {2 o" u& H
/* assign the tl som board LED-GPIOs*/
' \& C* d6 H$ }- j9 C# xstatic const short da850_evm_tl_user_led_pins[] = {
( w$ ]# x7 \5 E /* These pins are definition at <mach/mux.h> file */
3 |3 I, ^7 u( O6 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' h) {8 G7 l# G ?9 W -1
& v& k* A5 J6 s};0 }! [: b+ E& M5 G3 K# t
8 D1 D+ \+ M, ~0 wstatic struct gpio_led da850_evm_tl_leds[] = {! I# @( N$ }* Q
{$ T1 x5 ~$ W1 m1 A4 A s
.active_low = 0,+ j5 u; A, {1 t8 b3 F) w8 m! \ Z2 G
.gpio = DA850_USER_LED0,/ O! J- b$ Y; D [
.name = "user_led0",
. E- S! m0 D& b ^. Q- }9 N$ N .default_trigger = "default-on",* O+ q# j5 M4 @
},
! Q3 Q, T3 j0 [9 h& U& H {& |6 J9 z) ]" O* Q
.active_low = 0,
9 r* p5 Q* \; E4 R! t' S9 Z .gpio = DA850_USER_LED1,
; k: M* U6 r8 t# q$ {4 F" ^9 I0 d/ ^ .name = "user_led1",2 r4 {0 @) D7 a- G0 A% c
.default_trigger = "default-on",
; U; ^: p0 H. d# g) M' w },
, s/ `+ s9 w" ?. D {) [* |, t4 @, a
.active_low = 0,3 {) `+ J/ C* T: e4 ~
.gpio = DA850_USER_LED2,# e W/ R& k+ M
.name = "user_led2",
( n: p! Q/ x& q& o' j p7 X5 ~ .default_trigger = "default-on",# a s4 \# F4 R4 l# G0 I& t5 F8 T; f" W9 a
},
1 }9 F: j4 U+ v5 Q* k P5 [ {
' Z% b5 w6 Q! T. M+ F .active_low = 0,
s8 K+ a0 q \2 K0 W+ C .gpio = DA850_USER_LED3,
2 y, S* v( c6 n .name = "user_led3",% P$ ^, D3 |1 n0 ? C7 T, T
.default_trigger = "default-on",8 r$ M7 h. A6 N V: b
},5 G! i' U% q+ \0 ]
};
/ m6 m1 |' w$ j/ n6 ~, ~# B% L3 n) h/ B. H4 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 T, z2 U) N/ P# P
.leds = da850_evm_tl_leds,
; \4 K' ~. {* B9 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; X4 e+ k& \3 ~1 N) ~3 s# G
};
* ?" Y3 w4 _4 W8 V5 a- P) z$ \& D5 G- ?2 [% G8 L0 C% H g+ e- A
static void led_dev_release(struct device *dev)
# i' I; M* ~ m{
5 j7 Y j& D3 l) M! p& U+ K};: g6 V1 |7 x- h& n3 J" W
. A" o' {3 h+ a9 ]. Rstatic struct platform_device da850_evm_tl_leds_device = {
2 V' q& U$ F4 E/ K# [: m .name = "leds-gpio",
5 \; Y. v% j& N+ T( u+ @ .id = 1,3 v9 G) R5 c' Q: C! I3 X! l
.dev = {5 c/ O0 k, G+ U7 f
.platform_data = &da850_evm_tl_leds_pdata,
; s U: `" o: I .release = led_dev_release,' i; c: S$ n. G
}
1 G$ B2 N0 J2 `9 C- S};
) g- }2 u/ v/ x( u, l; J8 d2 ?) P Q" N, }% }9 o/ P ^( G2 i! D. z
static int __init led_platform_init(void)
( `2 u; P# v3 w' [9 F{3 w6 H/ [% l2 y* e
int ret;
" e2 M+ [- ]( n8 \! r/ S8 h# S- N- \#if 0
+ f' q' X0 Q) a: D* L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ Q) U, k& v# X% E if (ret)2 H' P, ^ A: W$ F: B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 z: _5 `. `, f" j2 T7 j: [( x "%d\n", ret);
/ d; C P \2 w$ C#endif$ V& V! Q) f5 j$ _' H" V) n
ret = platform_device_register(&da850_evm_tl_leds_device);
' D/ G, B' ~6 Y if (ret)
: r% f) v9 k$ |) c* m, A" C' s! p. u pr_warning("Could not register som GPIO expander LEDS");
+ D2 T& k, L9 d' P; v* D* @ else
+ S8 L6 E- N" F' p7 O, a printk(KERN_INFO "LED register sucessful!\n");. F' Q5 ]9 u* p) f# K
( @) u" T$ Y+ Y
return ret;! j! b; l& ~% E4 I6 c+ O
}
. e$ T! C+ j& W/ X( z3 t: H+ _! q: r% E: ~, x
static void __exit led_platform_exit(void)0 B/ F( {6 z! E, n7 ]* v
{
1 y$ r& D, Q- \0 y2 Y platform_device_unregister(&da850_evm_tl_leds_device);
$ W! P& T @; j# [: F
J" ], o1 k- J3 y- K printk(KERN_INFO "LED unregister!\n");
. v! G8 Q( E$ M) u3 s% Y4 w}) o7 F: y+ d5 a
5 x5 j8 o, t$ F8 g9 T M8 E
module_init(led_platform_init); C9 m" o# T, C( o" p$ F- H
module_exit(led_platform_exit);+ M- w H/ y$ a& c' E, Z8 v D
/ |9 S; e4 a, S( ?+ Z, q6 r
MODULE_DESCRIPTION("Led platform driver");
! G! n/ S- P! B! k1 I+ HMODULE_AUTHOR("Tronlong");
7 f( q/ @' |' m( dMODULE_LICENSE("GPL");
/ _% F0 K" J8 u0 Y; s; H, G5 l. r3 C4 u- L8 O; B" G) u2 K+ t
|
|