|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 X- N! T: L+ w. |' t1 @: Z#include <linux/init.h>' q$ w1 }( e2 g: P8 v# s# _2 U: f2 T
#include <linux/module.h>) f3 M- p4 [4 {+ K, p2 k5 _( x
#include <linux/kernel.h>
4 b4 m) K9 F0 d1 m#include <linux/types.h>
! D% R1 U% s2 {* A9 A7 P#include <linux/gpio.h>
& W$ U# p* X: Y5 u7 N- \, ^& F4 l. |0 ^6 g#include <linux/leds.h>( c2 @8 |4 I1 s% y6 @) @
#include <linux/platform_device.h>
- J; k3 I; B$ t; l( M6 T8 e) N$ G7 ~, K. @
#include <asm/mach-types.h>3 D) F$ z- f; ]' G) \3 ^/ H! R: d0 B
#include <asm/mach/arch.h># T6 K( f/ s3 s' B
#include <mach/da8xx.h>
* W; K2 B1 H g#include <mach/mux.h>7 N+ f+ a; M Y! I- z! `6 O
7 z/ O4 |1 {7 m& y# T7 h8 C+ ?; a2 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) H7 Y, m, t9 I) o5 b+ Y& [% X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& G! |( Y' K) z8 f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% c8 a( r; b! n. B% {9 b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- S+ k1 K) D! d1 Y- y r( D3 ?
' [, i( L& D4 x) y0 r! v- P/* assign the tl som board LED-GPIOs*/
* k+ }- Q6 B2 [# @# M3 M: L) astatic const short da850_evm_tl_user_led_pins[] = {
% T+ D M9 h) q1 `% o /* These pins are definition at <mach/mux.h> file */
) d* U1 A! U: ]! @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& q% y8 D" o3 p% ?1 P9 x$ q -1
( ~$ [, ]) ~3 i};% G* |$ i4 ~1 ~4 o1 }$ \/ A
% `1 |: B$ O8 Y5 Y9 s" Gstatic struct gpio_led da850_evm_tl_leds[] = {: i/ G; z8 K/ z: z2 u1 F" K
{* v& [0 E/ u2 w! r
.active_low = 0,( _! ^. k* Y. i T2 L& Q) S
.gpio = DA850_USER_LED0,
5 j/ Y* k8 V S: Y% y" | .name = "user_led0",! t& y4 t6 V4 l
.default_trigger = "default-on",
9 S% {0 C/ s. [, \0 h( h# S }," Q! Z0 @7 J7 ^0 C- ?
{, i: Q) O7 z" E3 h4 A( _
.active_low = 0,
% T' {/ m Z: e9 t+ u .gpio = DA850_USER_LED1,
1 n4 ]3 R* z4 _: Y+ E$ g8 J .name = "user_led1",1 E2 K4 J: E! w! v6 d
.default_trigger = "default-on",
* \* v& E* a7 _. B0 W },
7 G3 G0 J$ I2 x4 f {
8 r8 d6 |4 D- e) D# K# J( L .active_low = 0,: m1 ?9 V- S% d" E4 Z% @. o1 M
.gpio = DA850_USER_LED2,
$ d/ f* l, R% `' f .name = "user_led2",
- m9 R2 R; K# }, Q1 h* K( V+ L8 z .default_trigger = "default-on",+ O- t' @$ Z; R
},
% }- B a8 ?6 x {
5 Y0 @5 B3 _, y .active_low = 0,. z+ Z5 h+ z) g5 g
.gpio = DA850_USER_LED3,
/ e, n) j! s* L% E. \% M: c .name = "user_led3",
) k! X7 U' B8 |0 h# W( |. S. ~ .default_trigger = "default-on",
" C# Q' ?4 W) o; Z6 {/ S( p },
5 v: V: ]1 ^- Y};
, H7 D' l8 @! k$ E$ ]
/ u) Z) S l+ X9 S" d% Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 K. E; d% z! l9 Q% h$ K4 f
.leds = da850_evm_tl_leds,
2 ^3 j* ^+ {, Z: G2 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 b& W3 S5 l9 c9 I/ z
};, s# ^6 m, Z: L3 g3 `
" b5 t" v3 d) V2 c! D+ [! O: gstatic void led_dev_release(struct device *dev). i" Q7 J& s0 X* ~5 h( ]4 u
{
" r$ e1 t" R. O2 J' O) @$ d};
* L$ P- H# S, e- W5 v
' ~' i# F. o$ G2 S. lstatic struct platform_device da850_evm_tl_leds_device = {
, v& `- A- w- z' b1 d .name = "leds-gpio",. K3 `4 X7 B) V
.id = 1,
: c4 J- y t3 q( v .dev = {
% C/ ~1 N' d/ A) H .platform_data = &da850_evm_tl_leds_pdata,
! Y/ a6 j$ m( i6 h0 g .release = led_dev_release,- [+ L% _- W {" W3 f
}
0 M, P/ S0 _: V0 V* t9 L0 w; R; Z3 i! d};% [- T/ a5 z% ~) {1 U J
$ [" S& z. h$ E' H2 f& Y* f8 Pstatic int __init led_platform_init(void)
% s. j' H+ V( f: w% T{7 a$ f: q- }9 u3 L# ^
int ret;
& j% o! T2 ^/ X6 J#if 0
' o5 ]+ k- J- M. c. ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
{0 P( U& w+ P/ o; a if (ret)
$ l2 h( X$ b# U. {+ N! I, x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 o% h2 q( b% b, _ ?+ N" V2 c "%d\n", ret);
6 [% I3 y+ s. k9 P; q" J#endif6 g- O1 l5 c. S. H7 J7 q$ o
ret = platform_device_register(&da850_evm_tl_leds_device);. ~/ ?0 K6 _' E" E
if (ret)" m5 T7 c9 p1 B, l; D% U
pr_warning("Could not register som GPIO expander LEDS");! h3 H# x3 h& P7 S
else+ {$ Z8 k/ a: | b& {
printk(KERN_INFO "LED register sucessful!\n");1 Q9 V& f9 { e2 H$ {
$ x% m( l0 m/ p' l8 r
return ret;7 t }( l% S/ e
}
n1 B1 F0 ?8 O2 z8 L$ q
0 E; P8 W) U# O2 Q4 @static void __exit led_platform_exit(void)
1 l: u, ^& `1 t3 \# Q( r{
1 L# E1 x# c! ~% ^& m; {# j! s2 ^ platform_device_unregister(&da850_evm_tl_leds_device);, \$ N V2 o8 G' z" a3 c0 m
" Y7 Z0 ~6 O4 H( y printk(KERN_INFO "LED unregister!\n");* S8 v, s5 l& Y5 e4 T# e2 k$ d v
}
2 N: A$ Q4 ?. y' X. x
0 J+ o) p. M1 J0 M8 B# [module_init(led_platform_init);
0 q3 s5 S" R6 q K7 Tmodule_exit(led_platform_exit);
, R# C/ |% q0 I* _$ H% Q& Z/ t4 o! y$ _4 R( o# Y4 T) v
MODULE_DESCRIPTION("Led platform driver");
/ I; A8 P- C0 y) }* XMODULE_AUTHOR("Tronlong");: c. S+ [( D5 ^) M$ y
MODULE_LICENSE("GPL");( K! V+ G4 a$ M' J8 ?; F% L
' p) x0 e0 E$ g L0 G1 D: P5 \ |
|