|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. c& J8 K" q; t
#include <linux/init.h>9 _8 e' Z/ `$ H4 N: U) n
#include <linux/module.h>
" ~; z6 Z0 i3 C1 [' U6 e#include <linux/kernel.h>
! I5 f, {! [ B4 X: s#include <linux/types.h>5 f7 \+ n& y1 c0 p
#include <linux/gpio.h>& `7 M4 t. V9 b+ y/ v) y$ s
#include <linux/leds.h>. A, W8 t0 R6 }5 r
#include <linux/platform_device.h>- P3 l+ W2 `. f# ~
4 d9 n, f8 J! R+ S#include <asm/mach-types.h># C" O( J/ [- c* f
#include <asm/mach/arch.h>
$ L: D9 A% {; J$ x" y#include <mach/da8xx.h>. s; a6 {# T T. Y6 N
#include <mach/mux.h> A) R! H/ ]; S' T
% ~( r1 K4 k9 ]" ~7 h4 O; w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( O* j$ ^6 J/ @4 Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% x) P9 r9 D6 ?. \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( T- I5 G& w+ H1 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% m, S8 ]5 Y | a% X7 [0 v6 p
, y; B3 D8 f* J/* assign the tl som board LED-GPIOs*/
+ w# N+ _; i5 astatic const short da850_evm_tl_user_led_pins[] = {3 _8 {% R j# s/ |! [4 f; p' r6 D
/* These pins are definition at <mach/mux.h> file */
0 q: ?; Z1 K2 p! f4 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 F) a+ O/ D! n3 B -1
: {% `3 `1 L; [. D, [2 I};% R3 \% o4 w5 V: U. M
: Q$ t6 ^' ~) R! D- mstatic struct gpio_led da850_evm_tl_leds[] = {$ O$ z5 C" m8 J
{2 J7 d3 J6 z' f- v: G
.active_low = 0,
( A. ?8 n! |- ^$ c, s" {1 R .gpio = DA850_USER_LED0,9 b! _% Z4 m$ L) o
.name = "user_led0",
" M) P/ s: }0 p/ F% w: m7 c2 | .default_trigger = "default-on",# G6 L3 b+ k0 D' v0 k. X# W0 Y/ G
},
B: h1 o$ `. I' a/ m* R {
# u$ s3 y; q0 Q5 D: L+ u! `6 K3 h; ` .active_low = 0,, c: N3 P% ?! x1 @4 Q
.gpio = DA850_USER_LED1,
! B! S1 }$ [2 e: i- [ .name = "user_led1",6 z8 E6 [$ i9 R' r$ T* E' j7 \
.default_trigger = "default-on",
( f* C) I: g2 \6 }/ f' } },
, O' C B1 X( I4 J {1 q/ p( \6 X" ?1 |" _" E/ K
.active_low = 0,7 {2 [7 W% [/ y0 j8 w% I
.gpio = DA850_USER_LED2,: G0 {, u- ^- A# N
.name = "user_led2",
5 ^0 B% C( ~2 G4 F .default_trigger = "default-on",4 ?9 ` e O* e
},; \. K, j( M' @
{
/ ]8 x$ s4 H$ [4 o/ [ .active_low = 0,
' x) H8 n) h# P2 u+ H .gpio = DA850_USER_LED3,
# Z5 Q; u3 J2 T6 `7 r& K .name = "user_led3",
$ c+ t4 I! n8 x; \. i9 g( G .default_trigger = "default-on",( P# H: t' C1 H* D+ `
},: A: }% M$ v2 Z" r# @
};# O7 z0 S" l9 E' u* k/ O: L, N
0 @9 D; P' M: U2 n5 d" u/ w$ [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 |& r: J9 `% a+ ]- I# z
.leds = da850_evm_tl_leds,3 s% l$ N0 t# ~2 z2 {6 y& n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; L) r5 L8 e' w3 }1 {
};
( S# E( r& d# }
0 j, J9 y2 k6 d- Q7 }! Y: N' rstatic void led_dev_release(struct device *dev)
( Z- ?8 g" f* P{- N R, X8 W3 ]1 Y, M- ]
};
3 _) ~# Z I% k$ L" f5 c5 }% d* G+ w8 @2 k% x, Z
static struct platform_device da850_evm_tl_leds_device = {. X4 _$ H& f; e9 J0 G
.name = "leds-gpio",8 H6 K& d3 D+ p4 E0 v* N3 v: W( z, B
.id = 1,% J' R/ A7 f2 f) K
.dev = {# \$ L) e( o% r# I/ p( m8 K% P
.platform_data = &da850_evm_tl_leds_pdata,
, L& l1 \8 n% N! h+ U8 } .release = led_dev_release,
- l2 q. Z O) D! D }+ \# i' M% a3 W0 p/ K" w8 p
};. t( d4 I9 T+ H9 k! @
6 ~2 Y+ j- v( Q2 Dstatic int __init led_platform_init(void)% M: ` w) h# t; F) h; f! \5 ~2 X1 e
{
' I/ }- z5 P$ E/ s& f! j0 W int ret;% U! }! F6 x; }5 f; L
#if 0
; Y" M" |# b, l* | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 b$ {: g+ Y' Z) L' t# }/ H2 v3 M0 s if (ret)
8 T/ R. b/ N f% r& V; O! _5 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' k; o( [% h) U3 T. H1 _
"%d\n", ret);; H+ t; N) o" s G' S1 ^
#endif
3 g' O" J/ g' j0 O ret = platform_device_register(&da850_evm_tl_leds_device);( Q% K5 w) ?& g: X9 T) \
if (ret) G0 a: u7 k- `$ |
pr_warning("Could not register som GPIO expander LEDS");9 i ? _( D- k0 P* U
else
7 O6 L5 T) |8 h ^5 D; M, N9 U printk(KERN_INFO "LED register sucessful!\n");
( ]6 g: X t" s7 h; `+ U _$ y5 I- J* h! N; J! j/ r8 }( A m
return ret;
" `( U2 \8 i9 b4 [& g5 a8 {8 }0 k}( y- P+ ?7 B5 n; H4 q: w: U
' f2 P; X8 E p$ V9 m& n
static void __exit led_platform_exit(void)
6 q( C7 _: l# L9 |3 ?7 e$ g% P{* y- J& y% }; O0 t# C
platform_device_unregister(&da850_evm_tl_leds_device);
( K5 A5 _0 E2 m" C. `* X3 n( r' z7 G( t! X0 q" {
printk(KERN_INFO "LED unregister!\n");
# w- H/ l0 k& t4 W) V0 j}+ g) F$ J+ o% v% [$ |
0 x* B8 V- `2 o& O9 m6 K2 I
module_init(led_platform_init);
, C" N0 j2 U$ [5 a+ `; r3 Zmodule_exit(led_platform_exit);
8 T1 \( e6 d( ]4 g4 e, }0 x: l1 l' f! r8 N: L
MODULE_DESCRIPTION("Led platform driver");
. }& V9 ]7 w5 D! xMODULE_AUTHOR("Tronlong");% u# [. J7 Z5 I' N" G: M( R
MODULE_LICENSE("GPL");4 |: Y, w7 Z3 K8 o2 |0 P! o( S
) d, {' u& }+ m% |' O
|
|